//遍历页面中span中属性xd:binding，放到js的hashtable中，便于以后读取
var opinionSpans=null;

//记录是否进行了正文修改
var contentUpdate=false;
var supervised = false;
var canUpdateContent=true;//正文是否允许修改
var hasTaohong = false;//套红记录
var changeWord = false ;//正文修改，主要用于区别套红 签章操作与修改正文
var changeSignature = false ;//签章
//全局变量，公文单是否修改标志
var isUpdateEdocForm=false;
try {
    getA8Top().endProc();
}
catch(e) {
}

function setMenuState(menu_id)
{
  var menuDiv=document.getElementById(menu_id);
  if(menuDiv!=null)
  {
    menuDiv.className='webfx-menu--button-sel';
    menuDiv.firstChild.className="webfx-menu--button-content-sel";
    menuDiv.onmouseover="";
    menuDiv.onmouseout="";
  }
}

function addReplySenderOpinion() {	
  initHtmlReplyOpinion=document.getElementById("replyDivsenderOpinion").innerHTML;
  document.getElementById("replyDivsenderOpinion").style.display = "block";
  var theForm = document.getElementsByName("repform")[0];
  theForm.postscriptContent.focus();
}

function replyCommentOK(date){
	parent.location.href=parent.location.href;
	/*
	var theForm = document.getElementsByName("repform")[0];
	
	
		var str = "";
		str += '<div class="div-float-clear" style="width: 100%">';
		str += '	<div class="sendOptionWriterName">' + date + '</div>';
		str += '	<div class="optionContent wordbreak">' + theForm.postscriptContent.value + '</div>';
		
		if(!fileUploadAttachments.isEmpty()){
			var atts = fileUploadAttachments.values();
			str += '	<div class="div-float attsContent">';
			str += '		<div class="atts-label">' + attachmentLabel + ' :&nbsp;&nbsp;</div>';
			
			for(var i = 0; i < atts.size(); i++) {
				str += atts.get(i).toString(true, false);
			}
			
			str += '	</div>';
		}
		str += '</div>';
		
		document.getElementById("replyDivsenderOpinionDIV").innerHTML += str;
		document.getElementById("replyDivsenderOpinion").innerHTML=initHtmlReplyOpinion;
		document.getElementById("replyDivsenderOpinion").style.display = "none";
	
	fileUploadAttachments.clear();
	*/
}
/**
 * 流程节点处理明细,直接调用协同的方法
 */
function showFlowNodeDetail(){
	var rv = getA8Top().v3x.openWindow({
        url: colWorkFlowURL + "?method=showFlowNodeDetailFrame&summaryId="+summary_id+"&appName=4&appTypeName="+appTypeName,
        dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
        width: "800",
        height: "600"
    });
}
//打印
function colPrint(){
	try {
		
		var printEdocBody= v3x.getMessage("edocLang.edoc_form");
		var edocBody = parent.detailMainFrame.contentIframe.document.getElementById("html").innerHTML;
		
		var x = edocBody.split("<INPUT ");
		var font_type = "";
		for(var i=0;i<x.length;i++){
			var x_a = x[i];
			var b = x_a.substring(x_a.indexOf(" style=\"")+8,x_a.indexOf("\" value"));
			if(b.indexOf("FONT")>-1){
				font_type = b;
			}
		}
		
		
		var re = /disabled/g;
		edocBody = edocBody.replace(re," READONLY=\"READONLY\"");
		
		re = /INPUT/g;
		edocBody = edocBody.replace(re,"INPUT style=\"border:0\"");			
					
		var a = edocBody.split("</SELECT>");
			var result = "";		
		
		for(var i=0;i<a.length;i++){
			var aa = a[i];
			var b = aa.substring(aa.indexOf("<SELECT"),aa.length+9);
			var bb = b.substring(b.indexOf("selected>")+9,b.length);
			var c = bb.substring(0,bb.indexOf("</OPTION>"));

			re = /<SELECT/g;
			var n = aa.replace(re,"<input type=\"text\" style=\"border:0;"+font_type+"\" value=\""+c+"\"><SELECT class=\"hidden\"");
			
			result += n;
		}
		
		//替换多行文本的回车,以及空格符号，让打印预览的页面的多行文本也有回车换行及空格的效果
		var textAreas = result.split("</TEXTAREA>");
		for(var i = 0;i<textAreas.length ; i++){
			var index = textAreas[i].indexOf("<TEXTAREA");
			if(index!=-1){
				var textArea = textAreas[i].substring(index);
				var ind = textArea.indexOf(">");
				var textAreaInnerHtml = textArea.substring(ind);
				var textAreaResult = textAreaInnerHtml.replace(/\r\n|\n/gm,'<br/>').replace(/\s/gm,'&nbsp;');
				result = result.replace(textAreaInnerHtml,textAreaResult);
			}
		}
		result = result.replace(new RegExp("TEXTAREA",'gm'),'DIV');
		
		//39413 打印出来的控件内的内容为黑色。
		result = result.replace(/link-blue/gm,'');
		
		//32718 处理意见过长，公文单打印异常。
		var a=result; 
		while(a.indexOf("<SPAN")!=-1){
			a=a.substring(a.indexOf("<SPAN")+1);
			var span=a.substring(0,a.indexOf(">"));
			var aft="";
			if(span.indexOf("shenpi")!=-1||span.indexOf("niwen")!=-1||
			span.indexOf("shenhe")!=-1||span.indexOf("fuhe")!=-1||
			span.indexOf("fengfa")!=-1||span.indexOf("huiqian")!=-1||
			span.indexOf("qianfa")!=-1||span.indexOf("zhihui")!=-1||
			span.indexOf("yuedu")!=-1||span.indexOf("banli")!=-1||
			span.indexOf("dengji")!=-1||span.indexOf("niban")!=-1||
			span.indexOf("wenshuguanli")!=-1||span.indexOf("chengban")!=-1||
			span.indexOf("otherOpinion")!=-1||span.indexOf("opinion")!=-1){
				aft=span.replace("SPAN","div");
				result=result.replace(span,aft);
			}
		}
		var edocBodyFrag = new PrintFragment(printEdocBody, result);
	} catch (e) {
	
	}	
	
	var cssList = new ArrayList();
	
	var pl = new ArrayList();
	pl.add(edocBodyFrag);
	
	var setHidden=false;
	var hiddenReplay=false;
	
	try{
	
	//增加发起人意见,处理意见打印
	var contentDoc=parent.detailMainFrame.contentIframe.document;
	var sendOpinionTitleObj = contentDoc.getElementById("sendOpinionTitle");
	var repDiv=contentDoc.getElementById("replyDivsenderOpinion");
	if(repDiv!=null && repDiv.style.display == "block")
	{
		repDiv.style.display="none";
		hiddenReplay=true;
	}
	
	
	if(contentDoc.getElementById("addSenderOpinionDiv")!=null)
	{
		setHidden=true;
		contentDoc.getElementById("addSenderOpinionDiv").style.visibility="hidden";
	}
	
	if(sendOpinionTitleObj!=null)	
	{
		var sendOpinionTitleFrag = new PrintFragment(sendOpinionTitleObj.innerHTML, contentDoc.getElementById("printSenderOpinionsTable").outerHTML);		
		pl.add(sendOpinionTitleFrag);
	}
	
	var dealOpinionTitleObj = contentDoc.getElementById("dealOpinionTitle");
	if(sendOpinionTitleObj!=null)	
	{
		var dealOpinionTitleFrag = new PrintFragment(dealOpinionTitleObj.innerHTML, contentDoc.getElementById("printOtherOpinionsTable").outerHTML);		
		pl.add(dealOpinionTitleFrag);
	}
	}catch(e){}	
	//cssList.add(v3x.baseURL + "/common/css/default.css");
	cssList.add(v3x.baseURL + "/apps_res/edoc/css/edoc.css");
	//cssList.add(v3x.baseURL + "apps_res/form/css/SeeyonForm.css");
	printList(pl,cssList);
	
	try{
	if(setHidden){contentDoc.getElementById("addSenderOpinionDiv").style.visibility="inherit";}
	if(hiddenReplay){contentDoc.getElementById("replyDivsenderOpinion").style.display = "block";}
	}catch(e){}
}


function compareTime(selObj){
	var newCollForm = document.getElementsByName("sendForm")[0];
	var advanceRemind = newCollForm.advanceRemind.options[newCollForm.advanceRemind.selectedIndex];
	var deadline = newCollForm.deadline.options[newCollForm.deadline.selectedIndex];
	var advanceRemindTime = new Number(advanceRemind.value);
	var deadLineTime = new Number(deadline.value);
	if(deadLineTime <= advanceRemindTime){
		alert(v3x.getMessage("edocLang.remindTimeLessThanDeadLine"));
		try{selObj.selectedIndex = 0;}catch(e){}
		return false;
	}
	return true;
}

//added by lius. 得到国际化字符串的简易表达，�?_("i18n key")
//_ = v3x.getMessage;

/**
 * 按map中的内容当成数据提交
 * 注意:javascript调用时最好用return false,以免默认的Form也被提交
 * target默认是_self,method默认是post
 */
function submitMap(map, action, target, method) {
    var form = document.createElement("form");
	form.setAttribute('method',method ? method : 'post');
	form.setAttribute('action',action);
	form.setAttribute('target',target ? target:'');
	
    document.body.appendChild(form);
    for (var item in map) {
        //自定义元素的
        if ((typeof(map[item]) == "object") && ("toFields" in map[item])) {
            var fields = map[item].toFields();
            //need jquery support
            $(form).append(fields);
        } else if (! (map[item] instanceof Array)) {
            var value = map[item];
            var field = document.createElement('input');
            field.setAttribute('type','hidden');
            field.setAttribute('name',item);
            field.setAttribute('value',value);
            form.appendChild(field);
        } else {
            var arr = map[item];
            for(var i = 0; i < arr.length; i++) {
                var value = arr[i];
                var field = document.createElement('input');
                field.setAttribute('type','hidden');
                field.setAttribute('name',item);
                field.setAttribute('value',value);
                form.appendChild(field);
            }
        }
    }
    try{    	
    	var tempInput = document.createElement('INPUT');
    	tempInput.setAttribute('type','hidden');
    	tempInput.setAttribute('name','appName');
    	tempInput.setAttribute('value','4');
    	form.appendChild(tempInput);
    	var edocType=document.getElementById('theform')['edocType'].value;
    	
    	var tempInput2 = document.createElement('INPUT');
    	tempInput2.setAttribute('type','hidden');
    	tempInput2.setAttribute('name','edocType');
    	tempInput2.setAttribute('value',edocType);
    	form.appendChild(tempInput2);
    }catch(e){}
    form.submit();
}

function map2params(map) {
    var container = [];
    for (var item in map) {
        if (! (map[item] instanceof Array)) {
            var value = map[item];
            var str = item + "=" + escape(value);
            container[container.length] = str;
        } else {
            var arr = map[item];
            for (var index in arr) {
                var value = arr[index];
                var str = item + "=" + escape(value);
                container[container.length] = str;
            }
        }
    }
    var result = container.join("&");
    return result;
}

var hasWorkflow = false;

//var workitemSelected = [];
//isFromTemplate
//通过ajax加载了模板的选人界面，并手工选了人。
var loadAndManualSelectedPreSend = false;
var isAllMember = true;
var isCheckNodePolicyFlag = false;

//Ajax判断文号定义是否被删除，并且判断内部文号是否已经存在
function checkMarkDefinitionExsit(definitionId,doc_mark,num,selectMode,summaryId){
	try {
		var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocController", "checkEdocMark", false);
		requestCaller.addParameter(1, "Long", definitionId);
		requestCaller.addParameter(2,'String',doc_mark);
		requestCaller.addParameter(3,'Integer',selectMode);
		requestCaller.addParameter(4,'String',summaryId);
		var rs = requestCaller.serviceRequest();
		//rs:0,0 (返回以,连接的两个整数)   （0：已删除文号定义 1：未删除文号定义）|(0:未使用内部文号 | 1：已使用该内部文号)
		var ret=rs.split(",");
		if(ret[0]== "0"){//已经被删除
			if(num==1){
				alert(_("edocLang.doc_mark_definition_alter_deleted"));
			}else if(num==2){
				alert(_("edocLang.doc_innermark_definition_alter_deleted"));
			}
			return false;
		}
		if(num==2){//内部文号
			if(ret[1]=="1"){ //内部文号已经存在
				alert(_("edocLang.doc_innermark_used"));
				return false;
			}
		}
		return true;
	}
	catch (ex1) {
		alert("Exception : " + ex1);
		return false;
	}	
}
//检查文号是否是格式良好的。
function isEdocMarkWellFormated(edocmark){
    var arr=edocmark.split("\|");
    if(!(arr.length==4 || arr.length==1)){//直接登记的时候是1
        alert(_("edocLang.edoc_mark_isnotwellformated"));
        return false;
    }
    return true;
}
function checkMarkDefinition(theForm){
	 //下拉："-2835738348978420994|不按年度]第0001号|1|1" 
	 //断号： "-4856736416063797664|BB]第0001号||2"
	 //输入: "0|9999||3
	 var summaryId=document.getElementsByName("summaryId")[0].value;
	 var edocMarkObj = theForm.elements["my:doc_mark"]; 
	 if(edocMarkObj){
	 	var edocmark=edocMarkObj.value;
	 	var definitionId=edocmark.substring(0,edocmark.indexOf("|"));//文号定义ID
	 	//var edocmarkString=edocmark.substring(edocmark.indexOf("|")+1);
	 	//var doc_mark=edocmarkString.substring(0,edocmarkString.indexOf("|"));//文号
	 	var selectMode=edocmark.substring(edocmark.length-1);
	 	if(definitionId!=0){
	 		if(!checkMarkDefinitionExsit(definitionId,null,1,selectMode,summaryId)){
	 			return false;
	 		}
	 	}
	 }
	 var edocMarkObj = theForm.elements["my:doc_mark2"]; 
	 if(edocMarkObj){
	 	var edocmark=edocMarkObj.value;
	 	var definitionId=edocmark.substring(0,edocmark.indexOf("|"));//文号定义ID
	 	//var edocmarkString=edocmark.substring(edocmark.indexOf("|")+1);
	 	//var doc_mark2=edocmarkString.substring(0,edocmarkString.indexOf("|"));//文号
	 	var selectMode=edocmark.substring(edocmark.length-1);
	 	if(definitionId!=0){
	 		if(!checkMarkDefinitionExsit(definitionId,null ,1,selectMode,summaryId)){
	 			return false;
	 		}
	 	}
	 }
	 var edocMarkObj = theForm.elements["my:serial_no"]; 
	 if(edocMarkObj){
	 	var edocmark=edocMarkObj.value;
	 	var definitionId=edocmark.substring(0,edocmark.indexOf("|"));//文号定义ID
	 	var edocmarkString=edocmark.substring(edocmark.indexOf("|")+1);
	 	var serial_no=edocmarkString.substring(0,edocmarkString.indexOf("|"));//文号
	 	var selectMode=edocmark.substring(edocmark.length-1);
	 	if(serial_no!=""){
	 		if(!checkMarkDefinitionExsit(definitionId,serial_no,2,selectMode,summaryId)){
	 			return false;
	 		}
	 	}
	 }
	 return true;
}
function send() {
	
	 var theForm = document.getElementsByName("sendForm")[0];
	 //增加对公文文号长度校验，最大长度不能超过66，主要考虑归档时，doc_metadata表长度200
     if(!checkEdocMark()) return;
     //验证文号定义是否存在
	 if(!checkMarkDefinition(theForm))return false;
	//验证交换单位是否有重复 -- start --
	var bool = checkExchangeAccountIsDuplicatedOrNot();
	
	if(bool == false){
		alert(_("edocLang.exchange_unit_duplicated"));
		return;
	}
	// -- end --
	if(validFieldData()==false){return;}
	if(compareTime()==false){return;}
	
    if (!theForm) {
        return;
    }
    //如果是退回拟稿人操作，拟稿人重新发起，action在sendBackToDraft方法中指定
    var choose =  document.getElementById("draftChoose");
    if(!choose || choose.value=="")
    	theForm.action = genericURL + "?method=send";
    if (checkForm(theForm)) {	
    	//文单元素非空验证 wangjingjing begin
        var value;
		var msg = ""; 
		var inputObj;
		var aField;
		var strTmp;
		for(var i = 0; i <fieldInputListArray.length; i++)
		{
			aField=fieldInputListArray[i];
			inputObj=document.getElementById(aField.fieldName);
			if(inputObj==null || inputObj.disabled==true){continue;}
			if(aField.required == "true" && inputObj.value.length == 0){
				strTmp = _("edocLang.edoc_"+aField.fieldName.substring(3)+"_alter_not_null")+"";
				if(strTmp == "undefined"){
					strTmp =  aField.fieldName.substring(3)+_("edocLang.edoc__alter_not_null")+"";
				}
				msg += strTmp+"\r\n";
			}
		}
		if(msg.length > 0){
			alert(msg);
			return;
		}
		//文单元素非空验证 wangjingjing end
        
    	//标题不能为空并且不含有特殊字符	
    	if(!checkSubject(theForm)){return;}
    	
    	
    	
    	// changyi 将以前的主送单位不能为空的判断取消，因为wangjingjing已经在上面加上了表单元素的判断了
    	//检查主送单位、主送单位2的是否设置有值
		//if(!checkSendUnitAndSendUnit2(theForm)){return;}
        if (!checkSelectWF()) {        
            return;
        }
       
        //检查签报公文文号是否已使用
        var edocMarkObj = document.getElementById("my:doc_mark");
        if(edocMarkObj){
	        var edocMark = _getWordNoValue(edocMarkObj);
	        var edocType = document.getElementById("edocType").value;
	        var summaryId=document.getElementById("summaryId").value;
	        if(edocType == "2" && edocMark != "" && !loadAndManualSelectedPreSend && checkMarkHistoryExist(edocMark,summaryId)){
	        	return;
	        }
        }
        //var html = $('#processModeSelectorContainer').html();
    	//$('#processModeSelectorContainer').html("");
    	if (!loadAndManualSelectedPreSend) {
            disableButtons();
            $('#sendForm').ajaxSubmit({
                //url : colWorkFlowURL + "?method=preSend&isFromTemplate="+isFromTemplate,
            	url : colWorkFlowURL + "?method=prePopNew&isFromTemplate="+isFromTemplate,
                type : 'POST',
                async : false,
                success : function(data) {
                    //$('#processModeSelectorContainer').html(data);
                	//alert("data:="+data);
                	//赋值给页面的popJsonId隐藏域
                	document.getElementById("popJsonId").value=data;
                	//转换成页面js的json对象
                	var dataObj= eval('('+data+')');
                	var invalidateActivity= dataObj.invalidateActivity;
                	//alert("invalidateActivity:="+invalidateActivity);
                	if(dataObj.invalidateActivity!=""){
                	//if(document.getElementById("invalidateActivity")){
                    	alert(_("collaborationLang.collaboration_invalidateActivity", dataObj.invalidateActivity));
                        enableButtons();
                    	return;
                    }
                	//alert("dataObj.isPop:="+dataObj.isPop);
    	            var ret = manualSelectByProcessModePop(dataObj.isPop,dataObj.hasNewflow);
                    //var ret = manualSelectByProcessMode();
                    if (!ret) {
                    	//$('#processModeSelectorContainer').html("");
                        loadAndManualSelectedPreSend = false;
                        enableButtons();
                        return;
                    } else {
                        loadAndManualSelectedPreSend = true;
                        if(document.getElementById("processXML") && document.getElementById("desc_by")){
                        	var processXML = document.getElementById("processXML").value;
                        	var desc_by = document.getElementById("desc_by").value;
                        	if(processXML != "" && desc_by != ""){
                        		document.getElementById("process_xml").value = processXML;
                        		document.getElementById("process_desc_by").value = desc_by;
                        	}
                        }
                        send();
                    }
                }
            });
            return;
        }

        //节点权限引用更新
		if(!isCheckNodePolicyFlag){
			var policyArr = new Array();
		    var itemNameArr = new Array();
		    if(nodes != null && nodes.length>0){
		    	for(var i=0;i<nodes.length;i++){
		    		var policyName = policys[nodes[i]].name;
		    		var itemName = policys[nodes[i]].value;
		    		policyArr.push(policyName);
		    		itemNameArr.push(itemName);
		    	}
		    }
		   	
		   	if(policyArr.length > 0){
				try {
					var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "checkNodePolicy", false);
					requestCaller.addParameter(1, "String[]", policyArr);
					requestCaller.addParameter(2, "String[]", itemNameArr);
					requestCaller.addParameter(3, "String", theForm.loginAccountId.value);
					var rs = requestCaller.serviceRequest();
					if(rs == "1"){
						alert(_("collaborationLang.node_policy_not_existence"));
						return;
					}
				}
				catch (ex1) {
					alert("Exception : " + ex1);
					return;
				}
		   	}
		}

        //$('#processModeSelectorContainer').html(html);
        //保存正文
       // checkExistBody();
        fileId=newEdocBodyId;
        if(!saveOcx())
        {
        	enableButtons();
        	return;
        }

        saveAttachment();

        disableButtons();

        isFormSumit = true;
        
        var branchNodes = document.getElementById("allNodes");
        if(branchNodes && branchNodes.value){
        	theForm.action += "&branchNodes=" + branchNodes.value;
        }

        theForm.target = "_self";     
        
        try{adjustReadFormForSubmit();}catch(e){}
        
        if(nodes != null && nodes.length>0){
        	var hidden;
        	for(var i=0;i<nodes.length;i++){
		        hidden = document.createElement('<INPUT TYPE="hidden" name="policys" value="' + policys[nodes[i]].name + '" />');
		        theForm.appendChild(hidden);
		        hidden = document.createElement('<INPUT TYPE="hidden" name="itemNames" value="' + policys[nodes[i]].value + '" />');
		        theForm.appendChild(hidden);
	        }
        }
        
        var party = document.getElementById("my:party");
        if(party){
        	document.getElementById("edocGovType").value="party";
        }
        var administrative = document.getElementById("my:administrative");
        if(administrative){
        	document.getElementById("edocGovType").value="administrative";
        }
        
        try {
        	theForm.submit();
        } catch(e) {
        	reductClick(false);
            topLinkClick(false);
        }
        getA8Top().startProc('');
        reductClick(false);
        topLinkClick(false); 
    }
}
//检查标题是否含有特殊字符并且不能为空
function checkSubject(theForm){
    if(theForm.elements["my:subject"]==null || theForm.elements["my:subject"]==undefined) {
		alert(_("edocLang.edoc_inputSubject"));
		return false;
	}
    if(theForm.elements["my:subject"].value.trim()=="")	
	{
		alert(_("edocLang.edoc_inputSubject"));
		if(theForm.elements["my:subject"].disabled==true)
		{
			alert(_("edocLang.edoc_alertSetPerm"));
			return false;
		}    		
		theForm.elements["my:subject"].focus();
		return false;
	}
	if(!(/^[^\|"']*$/.test(theForm.elements["my:subject"].value))){
		alert(_("edocLang.edoc_inputSpecialChar"));
		if(theForm.elements["my:subject"].disabled==true)
		{
			alert(_("edocLang.edoc_alertSetPerm"));
			return false;
		}    		
		theForm.elements["my:subject"].focus();
		return false;
	}
	return true;
}
//检查主送单位、主送单位2的是否设置有值
function checkSendUnitAndSendUnit2(theForm){
	
	var sendAccount = document.getElementById("my:send_to");
	if(sendAccount && jsEdocType == 0){
		if(theForm.elements["my:send_to"].value.trim()==""){
			alert(_("edocLang.edoc_inputSendTo"));
	  		if(theForm.elements["my:send_to"].disabled==true){
				alert(_("edocLang.edoc_alertSetSendTo"));
				return false;
			}	  
	 		theForm.elements["my:send_to"].focus();
			return false;	
		}
	}
	
	var sendAccount2 = document.getElementById("my:send_to2");
	if(sendAccount2 && jsEdocType == 0){
		if(theForm.elements["my:send_to2"].value.trim()==""){
			alert(_("edocLang.edoc_inputSendTo2"));
	  		if(theForm.elements["my:send_to2"].disabled==true){
				alert(_("edocLang.edoc_alertSetSendTo"));
				return false;
			}	  
	 		theForm.elements["my:send_to2"].focus();
			return false;	
		}
	}
	return true;
}
function _saveOffice()
{
	try{
	var comm=document.getElementById("comm").value;
    var bodyType = document.getElementById("bodyType").value;
    //if(bodyType!="HTML" && comm=="register" && canUpdateContent==false)
    //登记正文编辑由开发控制，分发正文暂不做控制--唐桂林
    if(bodyType!="HTML" && (comm=="distribute"||comm=="register") && canUpdateContent==false)
    {//登记时office正文不可以修改，保存前修改为可编辑模式，否则不保存
     	updateOfficeState("1,0");
    }
	}catch(e)
	{
		alert(e.description);
	}
	return saveOffice();
}

/**
 * 保存待发
 */
function save() {
    if(!checkEdocMark()) return;
	//验证交换单位是否有重复 -- start --
	var bool = checkExchangeAccountIsDuplicatedOrNot();
	
	if(bool == false){
		alert(_("edocLang.exchange_unit_duplicated"));
		return;
	}

    var theForm = document.getElementsByName("sendForm")[0];
    theForm.action = genericURL + "?method=save";
    
	if(validFieldData()==false){return;}
	if(compareTime()==false){return;}
	
	//节点权限引用更新
	if(!isCheckNodePolicyFlag){
		var policyArr = new Array();
	    var itemNameArr = new Array();
	    if(nodes != null && nodes.length>0){
	    	for(var i=0;i<nodes.length;i++){
	    		var policyName = policys[nodes[i]].name;
	    		var itemName = policys[nodes[i]].value;
	    		policyArr.push(policyName);
	    		itemNameArr.push(itemName);
	    	}
	    }
		try {
			var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "checkNodePolicy", false);
			requestCaller.addParameter(1, "String[]", policyArr);
			requestCaller.addParameter(2, "String[]", itemNameArr);
			requestCaller.addParameter(3, "String", theForm.loginAccountId.value);
			var rs = requestCaller.serviceRequest();
			if(rs == "1"){
				alert(_("collaborationLang.node_policy_not_existence"));
				enableButtons();
				return;
			}
		}
		catch (ex1) {
			alert("Exception : " + ex1);
			return;
		}
	}	
	
    if (checkForm(theForm)) {
    	//标题不能为空并且不含有特殊字符	
    	if(!checkSubject(theForm)){return;}
    	//lijl注销---------------------------Start(和康雪确认过需求,在保存到草稿箱的时候无论文单定议的时候是否勾选都不需要判断这两项)
    	//检查主送单位、主送单位2的是否设置有值
		//if(!checkSendUnitAndSendUnit2(theForm)){return;}
    	//检查是否设置了工作流
    	//if (!checkSelectWF()) {        
        //    return;
       // }
    	//lijl注销---------------------------End(和康雪确认过需求,在保存到草稿箱的时候无论文单定议的时候是否勾选都不需要判断这两项)
        //检查签报公文文号是否已使用
        var edocMarkObj = document.getElementById("my:doc_mark");
        if(edocMarkObj){
	        var edocMark = _getWordNoValue(edocMarkObj);
	        var edocType = document.getElementById("edocType").value;
	        var summaryId=document.getElementById("summaryId").value;
	        if(edocType == "2" && edocMark != "" && !loadAndManualSelectedPreSend && checkMarkHistoryExist(edocMark,summaryId)){
	        	return;
	        }
        }
        //保存正文
       // checkExistBody();
       	fileId=newEdocBodyId;
        if (!saveOcx()) {
            return;
        }
        saveAttachment();
        disableButtons();
        isFormSumit = true;
        theForm.target = "_self";
        try{adjustReadFormForSubmit();}catch(e){}
        try {
        	if(window.dialogArguments) {
        		theForm.target = "formIframe";
        	}
        	theForm.submit();
        } catch(e) {
        	reductClick(false);
            topLinkClick(false);
        }
        //转发 中点击保存进草稿箱，就不调用进度条了，因为新打开的窗口无法调用
        if(transmitSend == 0){
        	getA8Top().startProc('');
        }
        
        reductClick(false);
        topLinkClick(false); 
    }
}

/**
 * 保存进退稿箱
 */
function saveToBackBox() {
    if(!checkEdocMark()) return;
	//验证交换单位是否有重复 -- start --
	var bool = checkExchangeAccountIsDuplicatedOrNot();
	
	if(bool == false){
		alert(_("edocLang.exchange_unit_duplicated"));
		return;
	}

    var theForm = document.getElementsByName("sendForm")[0];
    theForm.action = genericURL + "?method=save&saveToBackBox=true";
    
	if(validFieldData()==false){return;}
	if(compareTime()==false){return;}
	
	//节点权限引用更新
	if(!isCheckNodePolicyFlag){
		var policyArr = new Array();
	    var itemNameArr = new Array();
	    if(nodes != null && nodes.length>0){
	    	for(var i=0;i<nodes.length;i++){
	    		var policyName = policys[nodes[i]].name;
	    		var itemName = policys[nodes[i]].value;
	    		policyArr.push(policyName);
	    		itemNameArr.push(itemName);
	    	}
	    }
		try {
			var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "checkNodePolicy", false);
			requestCaller.addParameter(1, "String[]", policyArr);
			requestCaller.addParameter(2, "String[]", itemNameArr);
			requestCaller.addParameter(3, "String", theForm.loginAccountId.value);
			var rs = requestCaller.serviceRequest();
			if(rs == "1"){
				alert(_("collaborationLang.node_policy_not_existence"));
				enableButtons();
				return;
			}
		}
		catch (ex1) {
			alert("Exception : " + ex1);
			return;
		}
	}	
	
    if (checkForm(theForm)) {
    	//标题不能为空并且不含有特殊字符	
    	if(!checkSubject(theForm)){return;}
    	
    	/*
    	//检查主送单位、主送单位2的是否设置有值
		if(!checkSendUnitAndSendUnit2(theForm)){return;}
    	//检查是否设置了工作流
    	if (!checkSelectWF()) {        
            return;
        }*/
    	//GOV-3535 【公文管理-发文管理-拟文】在后台设置"主送单位"不是必填项。在前台可以直接发送，也可以保存至草稿箱，但是发送后退回到退稿箱，在退稿箱里点击编辑，然后点保存，提示"请选择主送单位"。
        //检查签报公文文号是否已使用
        var edocMarkObj = document.getElementById("my:doc_mark");
        if(edocMarkObj){
	        var edocMark = _getWordNoValue(edocMarkObj);
	        var edocType = document.getElementById("edocType").value;
	        var summaryId=document.getElementById("summaryId").value;
	        if(edocType == "2" && edocMark != "" && !loadAndManualSelectedPreSend && checkMarkHistoryExist(edocMark,summaryId)){
	        	return;
	        }
        }
        //保存正文
       // checkExistBody();
       	fileId=newEdocBodyId;
        if (!saveOcx()) {
            return;
        }
        saveAttachment();
        disableButtons();
        isFormSumit = true;
        theForm.target = "_self";
        try{adjustReadFormForSubmit();}catch(e){}
        try {
        	theForm.submit();
        } catch(e) {
        	reductClick(false);
            topLinkClick(false);
        }
        getA8Top().startProc('');
        reductClick(false);
        topLinkClick(false); 
    }
}

function saveOcx(){
	var bodyType = document.getElementById("bodyType").value;
	if(bodyType == 'Pdf'){
	    return savePdf();
	}else{
	    return _saveOffice();
	}
}
function resend(from) {
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return;
    }

    var checkedNum = 0;
    var summaryId = null;
    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            summaryId = id_checkbox[i].value;
            checkedNum ++;
        }
    }

    if (checkedNum == 0) {
        alert(_("edocLang.edoc_alertSelectResentItem"));
        return;
    }

    if (checkedNum > 1) {
        alert(v3x.getMessage("edocLang.edoc_alertCanotTurn"));
        return;
    }

    var data = {
        from : from,
        summaryId : summaryId
    }

    var action = collaborationCanstant.resendActionURL;
    var target = "_parent";
    var method = "GET";
    submitMap(data, action, target, method);
}

function checkSelectWF() {
    if (!hasWorkflow) {
        alert(v3x.getMessage("edocLang.edoc_selectWorkflow"));
        if(selfCreateFlow==false){return false;}
        doWorkFlow("new");

        return false;
    }

    return true;
}

function alertPigeonhole()
{
	alert(_("edocLang.edoc_alertPigeonhole"));
}

function sendFromWaitSend() {
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return;
    }


    var hasMoreElement = false;
    var isSendImmediate = false;
    var len = id_checkbox.length;
    var summaryId = "";
    var caseId = "";
    var processId = "";
    var hasTemplete = false;
    var substate=""; //待发子状态 1：草稿，2：回退 3：撤销
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
        	summaryId = id_checkbox[i].value;
        	caseId = id_checkbox[i].getAttribute("caseId");
        	substate = id_checkbox[i].getAttribute("substate");

        	if(isSendImmediate){
        		alert(v3x.getMessage("edocLang.edoc_alertDontSelectMulti"));
    			return;
        	}
        	
        	//草稿在没有拟文权限的情况下，不再允许发送
        	if(isEdocCreateRole==false && substate==1){
        		alert(v3x.getMessage("edocLang.alert_not_edoccreate"));
    			return;
        	}
        	if(substate == 4){         //退回拟稿人不允许直接发送
        		alert(v3x.getMessage("edocLang.edoc_alertUseModify"));
        		return;
        	}
        	
        	processId = id_checkbox[i].getAttribute("processId");
        	hasTemplete = id_checkbox[i].getAttribute("templeteId")!="";
        	if(hasTemplete){
        		alert(v3x.getMessage("edocLang.edoc_alertPleaseDoubleClick"));
        		return;
        	}
            hasMoreElement = true;
            isSendImmediate = true;
        }
    }
    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertSentItem"));
        return;
    }
	//check if need popup "select people" dialog	
	//模板公文不能够直接发送，所以这里不需要访问preSend匹配人和分支 modify by yuhj at 2010-8-13
    //但是非模板公文能从待办列表中选择直接发送，因此这里还是需要访问preSend(现在为prePop)匹配人，如果有离职人员，则应不让发送
	/*var html = $('#processModeSelectorContainer').html();	
	$('#processModeSelectorContainer').html("");
	if (!loadAndManualSelectedPreSend) {
	            disableButtons();   
	            $('#listForm').ajaxSubmit({url : genericURL + "?method=preSend&summaryId="+summaryId + "&caseId=" + caseId + "&processId=" + processId + "&currentNodeId=start&isFromTemplate="+hasTemplete,
	                type : 'post',
	                success : function(data) {                	
	                	if(data.trim().search("err:noflow")>=0)
						{
							alert(v3x.getMessage("edocLang.edoc_noWorkflowNoSend"));
							return;
						}
	                    $('#processModeSelectorContainer').html(data);
	                    if(document.getElementById("invalidateActivity")){
	                    	alert(_("collaborationLang.collaboration_invalidateActivity", document.getElementById("invalidateActivity").value));
	                        enableButtons();
	                    	return;
	                    }
	                    var ret = manualSelectByProcessMode();
	                    if (!ret) {
	                        loadAndManualSelectedPreSend = false;
	                        enableButtons();
	                        return;
	                    } else {
	                        loadAndManualSelectedPreSend = true;
	                        sendFromWaitSend();
	                    }
	                }
	            });
	            return;
	        }
	        $('#processModeSelectorContainer').html(html);*/
	//end 
    //alert("loadAndManualSelectedPreSend:="+loadAndManualSelectedPreSend);
    if(processId == null || processId=='') {
    	alert("该公文未编辑流程，请编辑后再发送。");
    	return;
    }
    if (!loadAndManualSelectedPreSend) {
    	disableButtons();   
        $('#listForm').ajaxSubmit({
            url : colWorkFlowURL + "?method=prePopNew&summaryId="+summaryId + "&caseId=" + caseId + "&processId=" + processId + "&currentNodeId=start&isFromTemplate="+hasTemplete,
        	type : 'post',
        	async : false,
            success : function(data) {                	
            	//赋值给页面的popJsonId隐藏域
            	document.getElementById("popJsonId").value=data;
            	//转换成页面js的json对象
            	var dataObj= eval('('+data+')');
            	var invalidateActivity= dataObj.invalidateActivity;
            	if(dataObj.invalidateActivity!=""){
                	alert(_("collaborationLang.collaboration_invalidateActivity", dataObj.invalidateActivity));
                    enableButtons();
                	return;
                }
                var ret = manualSelectByProcessModePop(dataObj.isPop,dataObj.hasNewflow);
                if (!ret) {
                    loadAndManualSelectedPreSend = false;
                    enableButtons();
                    return;
                } else {
                    loadAndManualSelectedPreSend = true;
                    sendFromWaitSend();
                }
            }
        });
        return;
    }
    
    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            var affairId = id_checkbox[i].getAttribute("affairId");

           // var c = document.createElement("<input type='hidden' name='affairId' value='" + affairId + "'>");     
            var c = document.createElement("input");
        	c.setAttribute('type','hidden');
        	c.setAttribute('name','affairId');
        	c.setAttribute('value',affairId);
        	
            theForm.appendChild(c);
        }
    }



    theForm.method = "post";
    theForm.action = genericURL + "?method=sendImmediate";
    theForm.target = "_parent";

    disableButtons();

    getA8Top().startProc('');


    theForm.submit();
}

function serializeElements(_elements) {
    function SerializableElement(_elements) {
        var elements = _elements;
        this.toFields = function() {
            if (!elements) {
                return "";
            }
            var personList = (elements && elements.length == 2) ? elements[0] : [];
            var flowType = (elements && elements.length == 2) ? elements[1] : 0;
            var str = "";
            for (var i = 0; i < personList.length; i++) {
                var person = personList[i];
                str += '<input type="hidden" name="userType" value="' + person.type + '" />';
                str += '<input type="hidden" name="userId" value="' + person.id + '" />';
                //        workFlowContent += person.name + ",";
            }
            str += '<input type="hidden" name="flowType" value="' + flowType + '" />';
            return str;
        }
        return this;
    }
    return SerializableElement(_elements);
}

function serializeElementsNoType(_elements) {
    function SerializableElement(_elements) {
        var elements = _elements;
        this.toFields = function() {
            if (!elements) {
                return "";
            }
            var str = "";
            var isShowShortName = false;
            if(document.getElementById("currentLoginAccountId")){
		    	var loginAccountId = document.getElementById("currentLoginAccountId").value;
			    for (var i = 0; i < elements.length; i++) {
				    var person = elements[i];
			    	if(person.accountId != loginAccountId){
			    		isShowShortName = true;
			    		break;
			    	}
			    }
			}
            
            for (var i = 0; i < elements.length; i++) {
                var person = elements[i];
                str += '<input type="hidden" name="userType" value="' + person.type + '" />';
                str += '<input type="hidden" name="userId" value="' + person.id + '" />';
                str += '<input type="hidden" name="userName" value="' + person.name + '" />';
                str += '<input type="hidden" name="accountId" value="' + person.accountId + '" />';
		        str += '<input type="hidden" name="accountShortname" value="' + person.accountShortname + '" />';
            }
            str += '<input type="hidden" name="isShowShortName" value="' + isShowShortName + '" />';
            return str;
        }
        return this;
    }
    return SerializableElement(_elements);
}

function serializePeople(elements) {
    if (!elements) {
        return "";
    }

    var personList = (elements && elements.length == 2) ? elements[0] : [];
    var flowType = (elements && elements.length == 2) ? elements[1] : 0;

    var arr = [];
    //    var str = "";
    //    var workFlowContent = "";
    for (var i = 0; i < personList.length; i++) {
        var person = personList[i];
        //        str += '<input type="hidden" name="userType" value="' + person.type + '" />';
        //        str += '<input type="hidden" name="userId" value="' + person.id + '" />';

        var obj = new Object();
        obj.name = "userType";
        obj.value = person.type;
        arr.add(obj);

        obj = new Object();
        obj.name = "userId";
        obj.value = person.id;
        arr.add(obj);

        //        workFlowContent += person.name + ",";
    }

    //    str += '<input type="hidden" name="flowType" value="' + flowType + '" />';
    var obj = new Object();
    obj.name = "flowType";
    obj.value = flowType;
    arr.add(obj);

    hasWorkflow = true;
    return arr;
}

//加签选人后的回调
function selectInsertPeople(elements) {
    document.getElementById("selectPeoplePanel").innerHTML = "";
    if (!elements) {
        return false;
    }

    var personList = elements[0] || [];
    var flowType = elements[1] || 0;

    var str = "";
    var workFlowContent = "";
    for (var i = 0; i < personList.length; i++) {
        var person = personList[i];
        str += '<input type="hidden" name="userType" value="' + person.type + '" />';
        str += '<input type="hidden" name="userId" value="' + person.id + '" />';
        str += '<input type="hidden" name="userName" value="' + person.name + '" />';
        str += '<input type="hidden" name="accountId" value="' + person.accountId + '" />';
        str += '<input type="hidden" name="accountShortname" value="' + person.accountShortname + '" />';
        str += '<input type="hidden" name="flowcomm" value="add" />';

        workFlowContent += person.name + ",";
    }
    str += '<input type="hidden" name="flowType" value="' + flowType + '" />';
    document.getElementById("process_desc_by").value = "people";

    document.getElementById("selectPeoplePanel").innerHTML = str;
    hasWorkflow = true;
    
    try { getA8Top().startProc(''); }catch (e) { }

    var form = document.forms.theform;
    form.action = genericURL+"?method=insertPeople";
    form.target = "showDiagramFrame";
    form.submit();
    return false;
}

//减签辅助函数 - 提交减签人员名单
function commitDeletePeople(summary_id, affairId) {
    var people = [];
    var userName=[];
    var userType=[];
    var accountId = [];
    var accountShortname = [];
    var data = {
        userId : [],
        summary_id : summary_id,
        affairId : affairId,
        userName :[],
        userType :[],
        accountId : [],
        accountShortname : []
    };
    $("INPUT").each(function() {
        if (this.name == "deletePeople" && this.checked) {
            people[people.length] = this.value;
            userName[userName.length] = this.pname;
            userType[userType.length] = this.ptype;
            accountId[accountId.length] = this.paccountId;
            accountShortname[accountShortname.length] = this.paccountShortName;
        }
    });
    if (people.length == 0) {
        alert("至少选择一项！");
        return false;
    }

    data.userId = people;
    data.userName=userName;
    data.userType=userType;
    data.accountId=accountId;
    data.accountShortname=accountShortname;
    
    try { getA8Top().startProc(''); }catch (e) { }
    submitMap(data, genericURL+"?method=deletePeople","showDiagramFrame");
    //    $("#deletePeoplePanel").html("").css("display", "none");
    $("#deletePeoplePanel").hide();
    //("").css("display", "none");
    //    $("#darkbox").hide();
}

//取消减签
function cancelDeletePeople() {
    $("#deletePeoplePanel").html("").css("display", "none");
    $("#darkbox").hide();
    //hide("fast");
}

//终止,要求保存终止的意见,附件信息
function stepStop(theForm)
{
	if(!checkModifyingProcessAndLock(theForm.processId.value, theForm.summary_id.value)){
		return;
	}
	
	//回退的时候清除匹配人员,避免因为下一节点没有匹配到人员禁止回退
	$('#processModeSelectorContainer').html("");
    if (checkForm(theForm))
    {
        if (!window.confirm(_("edocLang.edoc_confirmStepStopItem")))
        {
            return;
        }
                
        if(!parent.detailMainFrame.contentIframe.saveEdocForm())
		{
	  		return;
		}
		if(!parent.detailMainFrame.contentIframe.saveContent())
		{
	  		return;
		}
		if(!parent.detailMainFrame.contentIframe.saveHwData())
		{
	  		return;
		}
        
        theForm.action = genericURL + "?method=stepStop";
        saveAttachment();
        document.getElementById("processButton").disabled = true;
        try {
            document.getElementById("zcdbButton").disabled = true;
        } catch(e) {
        }
        
	    try { //如果是弹出窗口，则不能显示“处理中”
	        getA8Top().startProc('');
	    }
	    catch (e) {
	    }
	    
	    disableButton("stepStopSpan");
	    disableButton("stepBackSpan");
	    
        theForm.submit();
    }
}
//公文转发为，主要应用是收文转发文，发文也转发文
function transmitSend(summaryId,affairId)
{
	if(isEdocCreateRole!="true")
	{//没有公文发起权
		alert(_("edocLang.alert_not_edoccreate"));
		return;
	}
	//保存一份清除了痕迹的正文，否则查看转发的正文时，可以看到痕迹。
	fileId=transmitSendNewEdocId; 
	//var bodyType=parent.detailMainFrame.contentIframe.bodyType ;
  	if(typeof(bodyType)!="undefined" && bodyType!="HTML" && bodyType!="Pdf"){
  	    //如果清除痕迹失败就返回
  	   if(!(removeTrailAndSave())) return;
  	}
	var url=genericURL+"?method=newEdoc&comm=transmitSend&edocType=0&edocId="+summaryId+"&transmitSendNewEdocId="+transmitSendNewEdocId;
    if(top.dialogArguments)
    {
    	var parentUrl=top.dialogArguments.location.href;
    	//GOV-3339 公文管理-拟文，权限为封发，暂存代办，再进行转发、文单套红、正文套红时报脚本错误
		//处理时点击转发，处理页面可能是从待办和在办列表中 点出来的
    	if(parentUrl.search("method=listPending")>0 || parentUrl.search("method=listZcdb")>0)
    	{			
    		//修复bug GOV-3236 【公文管理】-【发文管理】-【待办】，公文转发页面，不能与横向菜单里的菜单切换，点击后没反应
    		//在top.dialogArguments.parent后加上listFrame
    		top.dialogArguments.parent.listFrame.location.href=url;
    		top.close();
    	}
		else
		{
			url=genericURL+"?method=entryManager&entry=sendManager&from=newEdoc&comm=transmitSend&edocType=0&edocId="+summaryId+"&transmitSendNewEdocId="+transmitSendNewEdocId;
			if(top.dialogArguments.contentFrame==undefined)
			{
                // 精灵打开
                if(top.contentFrame){
                    top.contentFrame.mainFrame.location.href=url;
                    return;
                }			
                top.dialogArguments.getA8Top().contentFrame.mainFrame.location.href=url;
                top.close();
			}
			else
			{
				top.dialogArguments.contentFrame.mainFrame.location.href=url;
				top.close();
			}
		}
    }
    else
    {
    	parent.parent.location.href=url;	
    }	
}
//回退,要求保存回退的意�?附件信息
function stepBack(theForm)
{
	if(!checkModifyingProcessAndLock(theForm.processId.value, theForm.summary_id.value)){
		return;
	}
	
	//回退的时候清除匹配人员,避免因为下一节点没有匹配到人员禁止回退
	$('#processModeSelectorContainer').html("");
    if (checkForm(theForm))
    {
        if (!window.confirm(_("edocLang.edoc_confirmStepBackItem")))
        {
            return;
        }
        if(typeof beforeSubmitButton)
        	beforeSubmitButton();
        
        //山西太原市政府二开  上卡功能  郝后成  2012-07-27
		var affairId = document.getElementById("affair_id").value;
	    var summaryId = document.getElementById("summary_id").value;
		undoEdocForm(affairId,summaryId,false,null);
        
        if(!contentIframe.saveEdocForm())
		{
	  		return;
		}
		if(!contentIframe.saveContent())
		{
	  		return;
		}
		if(!contentIframe.saveHwData())
		{
	  		return;
		}
		
		var optionType=document.getElementById("optionType").value;
		
		//这里在url后加上意见内容，不然controller中无法获得
		/*var contentOP = "";
		//意见不一定能填写
		if(contentIframe.document.getElementById("contentOP")){
			contentOP=contentIframe.document.getElementById("contentOP").value;
		}*/
        theForm.action = genericURL + "?method=stepBack&optionType="+optionType;
        saveAttachment();
        document.getElementById("processButton").disabled = true;
        try {
            document.getElementById("zcdbButton").disabled = true;
        } catch(e) {
        }
        
	    try { //如果是弹出窗口，则不能显示“处理中”
	        getA8Top().startProc('');
	    }
	    catch (e) {
	    }
	    
	    disableButton("stepStopSpan");
	    disableButton("stepBackSpan");
	    
        theForm.submit();
    }
}


//会签
function selectColAssign(elements) {
	if(!checkModifyingProcessAndLock(process_Id, summary_id)){
		return;
	}
	
    if (!elements || elements == undefined) return;
    var people = serializeElementsNoType(elements);
    if (!people) {
        return;
    }
    var data = {
        summary_id : summary_id,
        affairId : affairId,
        people: people,
        flowcomm:"col"
    };
    try { getA8Top().startProc(''); }catch (e) { }    
    submitMap(data, genericURL + "?method=colAssign","showDiagramFrame","post");
}

//传阅选人回调函数
function selectPassRead(elements) {
	if(!checkModifyingProcessAndLock(process_Id, summary_id)){
		return;
	}
	
    if (!elements || elements == undefined) return;
    var people = serializeElementsNoType(elements);

    if (!people) {
        return;
    }

    var data = {
        summary_id : summary_id,
        affairId : affairId,
        people: people,
        flowcomm:"chuanyue"
    };
    try { getA8Top().startProc(''); }catch (e) { }
    submitMap(data, genericURL + "?method=addPassRead","showDiagramFrame");
}

//会签
function colAssign(_summary_id, _processId, _affairId) {
	if(!checkModifyingProcessAndLock(_processId, _summary_id)){
		return;
	}
	
	//检测xmls是否已经被加载
	initCaseProcessXML();
	
    //设置成全局变量
    summary_id = _summary_id;
    affairId = _affairId;
    process_Id = _processId;
    selectPeopleFun_colAssign();
}

//传阅
function addPassInform(_summary_id, _processId, _affairId) {
	if(!checkModifyingProcessAndLock(_processId, _summary_id)){
		return;
	}
	
	//检测xmls是否已经被加载
	initCaseProcessXML();
	if(v3x.getBrowserFlag('pageBreak')){
	    //设置成全局变量
	    summary_id = _summary_id;
	    affairId = _affairId;
	    process_Id = _processId;
	    selectPeopleFun_passRead();
	}else{
		var app = document.getElementById("appName");
		var appName = "";
		if(app){
			appName = app.value;
		}
		var divObj = "<div id=\"addInformWin\" closed=\"true\">" +
					 	"<iframe id=\"addInformWin_Iframe\" name=\"addInformWin_Iframe\" width=\"100%\" height=\"100%\" scrolling=\"no\" frameborder=\"0\"></iframe>" +
					 "</div>";
		$(divObj).appendTo("body");
		$("#addInformWin").dialog({
			title: v3x.getMessage("collaborationLang.alert_select_person"),
			top: 50,
			left:50,
			width: 630,
			height: 450,
			closed: false,
			modal: true,
			buttons:[{
						text:v3x.getMessage("collaborationLang.submit"),
						handler:function(){
							var rv = $("#addInformWin_Iframe").get(0).contentWindow.OK();
							$('#addInformWin').dialog('destroy');
						}
					},{
						text:v3x.getMessage("collaborationLang.cancel"),
						handler:function(){
						$('#addInformWin').dialog('destroy');
						}
					}]
		});
		$("#addInformWin_Iframe").attr("src",colWorkFlowURL + "?method=preAddInform&summaryId=" + _summary_id + "&affairId=" + _affairId + "&processId=" + _processId + "&appName="+appName);
	}
}


function setPeopleFields(elements, frameNames) {
    var theForm = document.getElementsByName("sendForm")[0];
    document.getElementById("people").innerHTML = "";
    if (!elements) {
        return false;
    }

    var personList = elements[0] || [];
    var flowType = elements[1] || 0;
    var isShowShortName = elements[2];
    var isShowWorkflow = (flowType == "2");
    //多层    

    if (isShowWorkflow) {
        flowType = 0;
        elements[1]=0;
    }

    var str = "";
    var workFlowContent = "";
    for (var i = 0; i < personList.length; i++) {
    	if(i > 0){
    		workFlowContent += ",";
    	}
        var person = personList[i];
        str += '<input type="hidden" name="userType" value="' + person.type + '" />';
        str += '<input type="hidden" name="userId" value="' + person.id + '" />';
        str += '<input type="hidden" name="userName" value="' + escapeStringToHTML(person.name) + '" />';
        str += '<input type="hidden" name="accountId" value="' + person.accountId + '" />';
        str += '<input type="hidden" name="accountShortname" value="' + escapeStringToHTML(person.accountShortname) + '" />';

        workFlowContent += person.name + "("+defaultPermName+")";
    }

    str += '<input type="hidden" name="flowType" value="' + flowType + '" />';

    document.getElementById("people").innerHTML = str;

    hasWorkflow = true;
    isFromTemplate = false;

    document.getElementById("workflowInfo").value = workFlowContent;
    theForm.process_desc_by.value = 'people';
    window.selectedElements = elements;

    if (isShowWorkflow) {    //显示流程
        designWorkFlow(frameNames);
    }

    return true;
}


/*
 
function selectPolicy(nodeName, policyName, dealTerm, remindTime, processMode, isNewCollaboration) {
    var heightDifference = 0;
    if (isNewCollaboration) {
        heightDifference = 60;
    }
    var rv = v3x.openWindow({
        url: genericURL + "?method=selectPolicy&nodeName=" + encodeURIComponent(nodeName)
                + "&policyName=" + encodeURIComponent(policyName) + "&dealTerm=" + encodeURIComponent(dealTerm)
                + "&remindTime=" + encodeURIComponent(remindTime) + "&processMode=" + encodeURIComponent(processMode)
                + "&isNewCollaboration=" + encodeURIComponent(isNewCollaboration),

        height:300 + heightDifference,
        width:300
    });

    if (!rv || rv.length == 0) return null;
    return rv;
}

function checkPolicy(stateStr, nodeName, nodePolicy, receiveTime, dealTime, overtopTime) {
    v3x.openWindow({
        url: genericURL + "?method=checkPolicy&stateStr=" + encodeURIComponent(stateStr)
                + "&nodeName=" + encodeURIComponent(nodeName) + "&nodePolicy=" + encodeURIComponent(nodePolicy)
                + "&receiveTime=" + encodeURIComponent(receiveTime) + "&dealTime=" + encodeURIComponent(dealTime) + "&overtopTime=" + encodeURIComponent(overtopTime),
        height:310,
        width:300
    });
}
*/

function openDetail(subject, _url) {
	// 'subject'判断是否是交换公文
	if(subject == 'exchange'){
		_url = _url;	
	}else{	
    	_url = genericURL + "?method=detail&" + _url;
	}
   // _url = genericURL + "?method=detail&" + _url;
	
    var rv = v3x.openWindow({
        url: _url,
        FullScrean: 'yes',
        dialogType: 'open',
        dialogType: v3x.getBrowserFlag('pageBreak') == true ? 'modal' : '1'
    });

    if (rv == "true") {
    	//当从待办和待阅列表中打开处理页面提交后，只刷新列表页面不刷新整个框架页面
    	//不然从待登记中 转发文的公文，进行处理后会刷新整个框架转到收文待办
    	if(subject == 'listReading' || subject == 'listPending'){
    		document.location.reload();
    	}else{
    		try {
    			getA8Top().reFlesh();
    		} catch(e) {
    			document.location.reload();	
    		}    		
    	}
        //        parent.location.href = '../../../portal/_ns:YVAtMTBkZjFmNmRjMWItMTAwMDF8YzB8ZDB8ZV9zcGFnZT0xPS9jb2xsYWJvcmF0aW9uLmRv/seeyon/collaboration.psml?method=collaborationFrame&from=Pending'
        //        top.showPanel('collaboration_pending');
    }

}
//lijl添加
function openDetailInfo(subject, _url) {
    _url = genericURL + "?method=edocRegisterInfo&" + _url;
    var rv = v3x.openWindow({
        url: _url,
        workSpace: 'yes',
        dialogType: v3x.getBrowserFlag('pageBreak') == true ? 'modal' : '1'
    });

    if (rv == "true") {
        getA8Top().reFlesh();
        //        parent.location.href = '../../../portal/_ns:YVAtMTBkZjFmNmRjMWItMTAwMDF8YzB8ZDB8ZV9zcGFnZT0xPS9jb2xsYWJvcmF0aW9uLmRv/seeyon/collaboration.psml?method=collaborationFrame&from=Pending'
        //        top.showPanel('collaboration_pending');
    }

}

//打开收文关联的发文
function openRelationSendV(recEdocId,recType,forwardType){
	var url = "edocController.do?method=relationNewEdoc&recEdocId="+recEdocId+"&recType="+recType+"&forwardType="+forwardType+"&newDate="+new Date();
    var rv = v3x.openWindow({
  				url: url,
  				height : 600,
  				width  : 600 
  	});
	if (rv == "true") {
	  	getA8Top().reFlesh();
	}
}



/**
 * 删除
 */
function deleteIt() {
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return;
    }

    var hasMoreElement = false;
    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            hasMoreElement = true;
            break;
        }
    }

    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertDeleteItem"));
        return;
    }

    if (window.confirm(v3x.getMessage("edocLang.edoc_confirmDeleteItem"))) {
        theForm.action = deleteActionURL;

        disableButtons();
        theForm.target = "_self";
        theForm.submit();
    }
}

var page_types = {
    'draft' : 'draft',
    'sent' : 'sent',
    'pending' : 'pending',
    'finish' : 'finish'
}
function deleteItems(pageType) {
    if (!pageType || !page_types[pageType]) {
        alert('pageType is illegal:' + pageType);
        return false;
    }

    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return true;
    }

    var hasMoreElement = false;
    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            hasMoreElement = true;
            break;
        }
    }

    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertDeleteItem"));
        return true;
    }

    if (window.confirm(v3x.getMessage("edocLang.edoc_confirmDeleteItem"))) {
        theForm.action = collaborationCanstant.deleteActionURL;

        disableButtons();

        for (var i = 0; i < id_checkbox.length; i++) {
            var checkbox = id_checkbox[i];
            if (!checkbox.checked)
                continue;
            var affairId = checkbox.getAttribute("affairId");
            //var element = document.createElement("<INPUT TYPE=HIDDEN NAME=affairId value='" + affairId + "' />");
            var element = document.createElement("input");
            	element.setAttribute('type','hidden');
            	element.setAttribute('name','affairId');
            	element.setAttribute('value',affairId);
            theForm.appendChild(element);
        }

        //var element = document.createElement("<INPUT TYPE=HIDDEN NAME=pageType value='" + pageType + "' />");
        var element2 = document.createElement("input");
    	element2.setAttribute('type','hidden');
    	element2.setAttribute('name','pageType');
    	element2.setAttribute('value',pageType);
        theForm.appendChild(element2);

        theForm.target = "tempIframe";
        theForm.method = "POST";
        theForm.submit();
        return true;
    }
}

//取回
function takeBack(pageType) {
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return true;
    }

    var hasMoreElement = false;
    var len = id_checkbox.length;
    var countChecked = 0;
    var obj;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
        	obj = id_checkbox[i];
            hasMoreElement = true;
            countChecked++;
        }
    }

    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertTakeBackItem"));
        return true;
    }
    
    if(countChecked > 1){
    	alert(v3x.getMessage("edocLang.edoc_alertSelectTakeBackOnlyOne"));
        return true;
    }
	if(obj.nodePolicy == "zhihui" || obj.nodePolicy == "inform"){
    	alert(v3x.getMessage("collaborationLang.collaboration_zhihuiTakeBackItem"));
        return;
    }
    //已结束流程不能取回
    if(obj.finished == "true"){
    	alert(alert_cannotTakeBack);
    	return false;
    }
		//由主流程自动触发的新流程不可撤销
    if(obj.isNewflow == "true"){
    	alert(v3x.getMessage("collaborationLang.warn_workflowIsNewflow_cannotTakeBack"));
        return;
    }    
    
 	  var summaryId = obj.value;
    
	if(!checkModifyingProcess(obj.processId, summaryId)){
		return;
	}

    if (window.confirm(v3x.getMessage("edocLang.edoc_confirmTakeBackItem"))) {        
        theForm.action=collaborationCanstant.takeBackURL;

        disableButtons();
        var affairId = obj.getAttribute("affairId");
        
        //山西太原市政府二开  取回时还原原始文单，并且清除请示卡中的内容    郝后成  2012-07-27
        var summaryId = obj.value;
        undoEdocForm(affairId, summaryId, true);
        
        //var element = document.createElement("<INPUT TYPE=HIDDEN NAME=affairId value='" + affairId + "' />");
        var element = document.createElement('input');
        element.setAttribute('type','hidden');
        element.setAttribute('name','affairId');
        element.setAttribute('value',affairId);
       // var element1 = document.createElement("<INPUT TYPE=HIDDEN NAME=summaryId value='" + summaryId + "' />");
        var element1 = document.createElement('input');
        element1.setAttribute('type','hidden');
        element1.setAttribute('name','summaryId');
        element1.setAttribute('value',summaryId);
        
        theForm.appendChild(element);
        theForm.appendChild(element1);

       // var element = document.createElement("<INPUT TYPE=HIDDEN NAME=pageType value='" + pageType + "' />");
        var element3 = document.createElement('input');
        element3.setAttribute('type','hidden');
        element3.setAttribute('name','pageType');
        element3.setAttribute('value',pageType);
        
        theForm.appendChild(element3);

        theForm.target = "tempIframe";
        theForm.method = "POST";
        getA8Top().startProc('');
        theForm.submit();
        return true;
    }
}

//催办回调
function hastenCallback() {
    $("#flashContainer").children(".information").css("background-color", "yellow").html(_("collaborationLang.operation_completed"));
    setTimeout('$("#flashContainer").children(".information").hide()', 2000);
}

//催办提交
function submitHasten() {
    var val = $(".additional_remark");
    val = val[0].value;
    //[$(".additional_remark").length-1].val();
    //    TB_remove();
    $("#hastenPanel").hide();
    var data = {
        processId : processId,
        activityId : activityId,
        additional_remark : val
    };
    if ($("#flashContainer").children(".information").length == 0) {
        $("#flashContainer").prepend("<div class='information'>" + _("collaborationLang.operation_processing") + "</div>");
    }
    $("#flashContainer").children(".information").css("background-color", "#FF0000").show();


    $.post(collaborationCanstant.hastenActionURL, data, hastenCallback);
}

//催办功能的两个全局变量
var processId = null;
var activityId = null;
//催办
function hasten(_processId, _activityId) {
    processId = _processId;
    activityId = _activityId;
    //    TB_show(_("collaborationLang.hasten_caption"),"#TB_inline?width=300&height=400&inlineId=hastenPanel",false);

    $("#hastenPanel").show();


    return false;
}

//催办对话框取�?
function cancelHasten() {
    $("#hastenPanel").hide();
}


////催办
//function hastenItems(pageType) {
//    if (!pageType || !page_types[pageType]) {
//        alert('pageType is illegal:' + pageType);
//        return false;
//    }
//
//    var theForm = document.getElementsByName("listForm")[0];
//    if (!theForm) {
//        return false;
//    }
//
//    var id_checkbox = document.getElementsByName("id");
//    if (!id_checkbox) {
//        return true;
//    }
//
//    var hasMoreElement = false;
//    var len = id_checkbox.length;
//    for (var i = 0; i < len; i++) {
//        if (id_checkbox[i].checked) {
//            hasMoreElement = true;
//            break;
//        }
//    }
//
//    if (!hasMoreElement) {
//        alert(v3x.getMessage("edocLang.edoc_alertHastenItem"));
//        return true;
//    }
//
//    if (window.confirm(v3x.getMessage("edocLang.edoc_confirmHastenItem"))) {
//        theForm.action = collaborationCanstant.hastenActionURL;
//
//        disableButtons();
//
//        for (var i = 0; i < id_checkbox.length; i++) {
//            var checkbox = id_checkbox[i];
//            if (!checkbox.checked)
//                continue;
//            var affairId = checkbox.getAttribute("affairId");
//            var element = document.createElement("<INPUT TYPE=HIDDEN NAME=affairId value='" + affairId + "' />");
//            theForm.appendChild(element);
//        }
//
//        var element = document.createElement("<INPUT TYPE=HIDDEN NAME=pageType value='" + pageType + "' />");
//        theForm.appendChild(element);
//
//        theForm.target = "_self";
//        theForm.submit();
//        return true;
//    }
//}

//从待办列表中直接发送的选人界面
function selectPeopleSendImmediate() {
    selectPeopleFun_receive();
}

function selectPeopleFromWaitSend(elements) {
    var str = serializePeople(elements);

}

function forwardItem() {
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return true;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return true;
    }

    var selectedCount = 0;
    var summaryId = null;
    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            summaryId = id_checkbox[i].value;
            selectedCount ++;
        }
    }

    if (selectedCount == 0) {
        alert(v3x.getMessage("edocLang.edoc_alertSelectForwardItem"));
        return true;
    }

    if (selectedCount > 1) {
        alert(v3x.getMessage("edocLang.edoc_alertSelectForwardOnlyOne"));
        return true;
    }

    var rv = getA8Top().v3x.openWindow({
        url : genericURL + "?method=showForward&summaryId=" + summaryId,
        height : 400,
        width : 360
    });

    return true;
}

function initProcessXml(){
	document.getElementsByName("sendForm")[0].process_xml.value = caseProcessXML;
}

function disableButtons() {
    disableButton("send");
    disableButton("save");
    disableButton("saveAs");
    disableButton("templete");
    disableButton("delete");
}

function enableButtons() {
    enableButton("send");
    enableButton("save");
    enableButton("saveAs");
    enableButton("templete");
    enableButton("delete");
}

function openDetailNewWin(url) {
    var rv = getA8Top().v3x.openWindow({
        url: url,
        workSpace: "true"
    });

    if (rv != null && (rv == "true" || rv)) {
        refreshIt();
    }
}

//function selectWorkitemOrNot(checked, itemId) {
//    if (checked)
//        workitemSelected[workitemSelected.length] = itemId;
//    else {
//        for (var i = workitemSelected.length - 1; i >= 0; i--) {
//            if (workitemSelected[i] == itemId)
//                workitemSelected.splice(i, 1);
//        }
//    }
//}

function showDetail(detailURL1) {
    //    setTimeout("parent.detailFrame.location.href = '" + detailURL + "'",1000);
    parent.detailFrame.location.href = genericURL + "?method=detail&" + detailURL1;
}
//lijl添加2011-10-17,收文列表,点击进入详细信息
function showDetailInfo(detailURL1) {
    //    setTimeout("parent.detailFrame.location.href = '" + detailURL + "'",1000);
	//alert(genericURL + "?method=detail&" + detailURL1);
    parent.detailFrame.location.href = genericURL + "?method=edocRegisterDetail&" + detailURL1;
}
function doWorkFlow(flag) {
    if (flag == "no") {
        //TODO 清空流程
    }
    else if (flag == "new") {
    	try{	
        	var result=selectPeopleFun_wf();    
    	}catch(e){}    
    }
}
function selectPersonToXml()
{
  processing=true;
  var url=genericControllerURL + "collaboration/monitor&comm=toxml";
  var toXmlFrame=document.getElementById("toXmlFrame");
  toXmlFrame.src=url;
}

/**
 * 处理后事�?
 */
function doEndSign() {    
	if(window.opener){
		window.opener.location.reload();
		window.close();
	}
	
    if (window.dialogArguments) {
        window.returnValue = "true";
        top.close();
    }
    else {
        parent.location.href = genericURL + '?method=edocFrame&from=listPending&edocType='+edocType;
        getA8Top().showPanel('collaboration_pending');
    }
}

function doEndSign_pending(from,list) {    
	if(window.opener){
		window.opener.location.reload();
		window.close();
		return;
	}
	
    if (window.dialogArguments) {
        window.returnValue = "true";
    	top.close();
    }
    else {
    	var url = parent.location.href;
    	if(url.indexOf("list=reading") != -1){
    		parent.location.href = url;
    	}else{
    		parent.location.href = genericURL + '?method=edocFrame&from='+(from?from:'listPending')+'&edocType='+edocType+'&list='+(list?list:'notPending');
    	}
    	//getA8Top().showPanel('collaboration_pending');
    }
}

//签收后调用方法
function doEndSign(type) { 
	location.reload();
}

function manualSelectByProcessMode() {
	if(!document.getElementById("showProcessModeSelector")){
		alert("操作失败：网络异常，系统无法获取所需的提交数据。");
		return false;
	}
	
    var showProcessModeSelector = document.getElementById("showProcessModeSelector").innerText;
    if (showProcessModeSelector == '2') {
        var rv = v3x.openWindow({
            url: genericControllerURL + "collaboration/popupProcessModeSelector&app=edoc",
            width: "580",
            height: "500"
        });
        if (rv != "True") {
            return false;
        }
    }
    else if (showProcessModeSelector == '1') {
        //选人界面

    }
    return true;

}

/**
 * manualSelectByProcessModePop()
 * 弹出流程选择页面处理
 * @param isPop 是否弹出
 * @param hasNewflow 是否有新流程
 * @returns {Boolean}
 */
function manualSelectByProcessModePop(isPop,hasNewflow) {
	var popDataObj= $('#popJsonId').val();
	if(popDataObj==""){
		alert("操作失败：网络异常，系统无法获取所需的提交数据。");
		return false;
	}
    if (isPop=="true") {
        var rv = v3x.openWindow({
            url: genericControllerURL + "collaboration/popupProcessModeSelector&app=edoc",
            width: 580,
            height: 500
        });
        if (rv != "True") {
            return false;
        }
    }
    return true;
}

/**
 * 验证内部文号是否重复，除开自己。
 */
function checkSerialNoExcludeSelf(){
	//	格式：serialNoValue	"0|String||3"	手写输入
	
	var serialNo=document.getElementById("my:serial_no");
	if(!serialNo)	return true;
	var serialNoValueStr=serialNo.value;
 	var serialNoValueStr=serialNoValueStr.substring(serialNoValueStr.indexOf("|")+1);
 	var serialNoValue=serialNoValueStr.substring(0,serialNoValueStr.indexOf("|"));//文号
 	
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocController", "checkSerialNoExcludeSelf", false);
	requestCaller.addParameter(1, "String", summaryId);
	requestCaller.addParameter(2,"String",serialNoValue);
	var rs = requestCaller.serviceRequest();
	//(0:未使用内部文号 | 1：已使用该内部文号)
	if(rs == "1"){//已经被占用
		alert(_("edocLang.doc_innermark_used"));
		return false;
	}
	return true;
}
/**
 * 校验是否已经选择了归档路径
 */
function isSelectPigeonholePath(){
    var selectObj = document.getElementById("archiveId");
    if(selectObj){
        var archiveId=selectObj.value;
        if(archiveId == ''){
            alert(_("edocLang.edoc_alertPleaseSelectPigeonholePath"));
            return false;
        }
        //如果设置了预归档路径，Aajax判断归档路径是否存在,没有设置预归档为了性能则不判断。
        if(hasPrepigeonholePath == 'true'){
            if(!checkPigFolder(archiveId)) {
             //设置选择框可见
                var showPrePigeonhole = document.getElementById("showPrePigeonhole");
    	        var showSelectPigeonholePath = document.getElementById("showSelectPigeonholePath");
    	        if(showPrePigeonhole && showSelectPigeonholePath){
    	            showPrePigeonhole.style.display="none";
    	            showSelectPigeonholePath.style.display="";
    	        }
                return false;
            }
        }
        return true;
    }else{
         //TODO 页面没有找到对象
    }
    return false;
}
function checkPigFolder(archiveId){
    var requestCaller = new XMLHttpRequestCaller(this, "ajaxDocHierarchyManager", "docResourceExist", false);
	requestCaller.addParameter(1, "Long", archiveId);
	var rs = requestCaller.serviceRequest();
	if(rs == 'false'){
	   alert(_("edocLang.edoc_alertPigeonholeFolderNotExsit")); 
	   return false;
	}
	return true;
}
function doSign(theForm, action) {
    //验证归档路径的选择
    var pipeonhole=document.getElementById("pipeonhole");
    if(pipeonhole && pipeonhole.checked){//假设选择了处理后归档，则判断是否选择了文件路径 && 归档文件夹是否存在
        if(!isSelectPigeonholePath()) return;
    }
	//验证内部文号是否被占用
	if(contentIframe.isUpdateEdocForm){//修改了公文单
		if(!contentIframe.checkSerialNoExcludeSelf())return;
	}
	
	//增加对公文文号长度校验，最大长度不能超过66，主要考虑归档时，doc_metadata表长度200
    if(!contentIframe.checkEdocMark())
      	return;
	
	disabledPrecessButtonEdoc();
	//验证交换单位是否有重复 -- start --
	var bool =contentIframe.checkExchangeAccountIsDuplicatedOrNot();
	
	if(bool == false){
		alert(_("edocLang.exchange_unit_duplicated"));
		disabledPrecessButtonEdoc(false);
		return;
	}
	
	if (checkForm(theForm)) {
		
	//意见不能为空	
	var content = document.getElementById("contentOP");
	var opinionPolicy = document.getElementById("opinionPolicy");
	if(opinionPolicy && opinionPolicy.value == 1 && content){
		if(content.value == ''){
			alert(v3x.getMessage("edocLang.edoc_opinion_mustbe_gived"));
			disabledPrecessButtonEdoc(false);
			return;
		}
	}
	
//	if (!manualSelectByProcessMode())
//        return;

	if(!checkModifyingProcess(theForm.processId.value, theForm.summary_id.value)){
		disabledPrecessButtonEdoc(false);
		return;
	}

	//检测xmls是否已经被加载
	//initCaseProcessXML();

	//节点匹配
	    //var html = $('#processModeSelectorContainer').html();
	    //$('#processModeSelectorContainer').html("");
	    if (theForm.isMatch.value == "true" && !loadAndManualSelectedPreSend) {
	    	//disableButtons();		    	
	        $('#theform').ajaxSubmit({
	        	//url : colWorkFlowURL + "?method=preSend&isFromTemplate="+templateFlag,
	        	url : colWorkFlowURL + "?method=prePopNew&isFromTemplate="+templateFlag,
	            type : 'POST',
	            async : false,
	            success : function(data) {
	            	//$('#processModeSelectorContainer').html(data);
	            	//赋值给页面的popJsonId隐藏域
	            	document.getElementById("popJsonId").value=data;
	            	//转换成页面js的json对象
	            	var dataObj= eval('('+data+')');
		            //jQuery的html方法有性能问题
		            //document.getElementById('processModeSelectorContainer').innerHTML= data;
		            var invalidateActivity= dataObj.invalidateActivity;
	            	if(dataObj.invalidateActivity!=""){
                    	//alert(_("collaborationLang.collaboration_invalidateNode", document.getElementById("invalidateActivity").value));
                    	alert(_("collaborationLang.collaboration_invalidateNode", dataObj.invalidateActivity));
                    	disabledPrecessButton(false);
                    	return;
                    }
		            var ret = manualSelectByProcessModePop(dataObj.isPop,dataObj.hasNewflow);
		            //var ret = manualSelectByProcessMode();
		            if (!ret) {
		            	loadAndManualSelectedPreSend = false;
		                //$('#processModeSelectorContainer').html("");
		                enableButtons();
		                disabledPrecessButtonEdoc(false);
		                return;
		            } else {
		            	loadAndManualSelectedPreSend = true;
		                doSign(theForm, action);
		            }
	            }
	        });
	        return;
	    }
	    //$('#processModeSelectorContainer').html(html);

	if(!contentIframe.saveEdocForm())
	{
		disabledPrecessButtonEdoc(false);
	  return;
	}
	checkExistBody();
	
	if(!saveContent())
	{
		disabledPrecessButtonEdoc(false);
	    return;
	} 
	//word转PDF
	//try{if(!convertToPdf(theForm))return false; }catch(e){}
	
	if(!contentIframe.saveHwData())
	{
		disabledPrecessButtonEdoc(false);
	    return;
	}
    
/*
        if (document.getElementById("delete").checked && !window.confirm(_("edocLang.edoc_confirmSignAfterDelete"))) {
            return;
        }

        saveAttachment();
        document.getElementById("processButton").disabled = true;
        try {
            document.getElementById("zcdbButton").disabled = true;
        } catch(e) {
        }
*/

		superviseRemindMode();
		//var bool = superviseCheck();
		//if(bool==false){
		//	return false;
		//}
		if(!checkModifyingProcess(theForm.processId.value, theForm.summary_id.value)){
			disabledPrecessButtonEdoc(false);
			return;
		}
		//保存当前处理人提交的处理意见所带的附件
		saveAttachment();
		
		if(contentIframe.checkUpdateHw()){				
		  try{
			  recordChangeWord(theForm.affair_id.value ,theForm.summary_id.value ,",wendanqianp",theForm.ajaxUserId.value);			
			}catch(e){}
		}	    
		var optionType=document.getElementById("optionType").value;
		var optionId=document.getElementById("optionId").value;
		var affairState=document.getElementById("affairState").value;
		var summary_id=document.getElementById("summary_id").value;
		var policy=document.getElementById("policy").value;
		
		var docMark = "";
		//changyi 加上公文文号
		if(contentIframe.document.getElementById("my:doc_mark")){
			docMark = contentIframe.document.getElementById("my:doc_mark").value;
		}
		var serialNo = "";
		if(contentIframe.document.getElementById("my:serial_no")){
			serialNo = contentIframe.document.getElementById("my:serial_no").value;
		}
		
		//lijl添加,添加参数,意见显示的设置格式
		action+="&optionType="+optionType+"&summary_id="+summary_id+"&docMark="+docMark+"&serialNo="+serialNo;
		theForm.action = action;
		var branchNodes = document.getElementById("allNodes");
        if(branchNodes && branchNodes.value){
        	theForm.action += "&branchNodes=" + branchNodes.value;
        }
        theForm.method = "POST";
        theForm.target = "_self";
        theForm.submit();
        try { //如果是弹出窗口，则不能显示“处理中”
	        getA8Top().startProc('');
        }
        catch (e) {
        }
        
        return;
    }
    disabledPrecessButtonEdoc(false);
}
function convertToPdf(){
    //只有WORD和WPS具有转PDF的功能
    var bodyType=document.getElementById("bodyType").value;
    if( bodyType=="OfficeWord"  ||  bodyType=="WpsWord" ){
       if(convertWordToPdf()){
    	   alert(v3x.getMessage("edocLang.edoc_tans2PdfSuccess"));
       }else{
    	   alert(v3x.getMessage("edocLang.edoc_tans2PdfError"));
       }
    }else{
    	alert(v3x.getMessage("edocLang.edoc_tans2PdfOnlyWordAndWps"));
    }
    
}
function convertWordToPdf(){ 
    var isunit     = document.getElementById("isUniteSend");
	var hasExchange = document.getElementById("edocExchangeType_depart");
	var newPdfIdFirst  = document.getElementById("newPdfIdFirst").value;
	var newPdfIdSecond = document.getElementById("newPdfIdSecond").value;
	//if(hasExchange && canTransformToPdf=="true"){
	    
	     //联合发文不支持转PDF
     if(isunit && isunit.value=="true") return true;
     
     if(!transformWordToPdf(newPdfIdFirst))
     {
       return false;
     }
	     //联合发文暂时不支持转PDF，但是代码机构基本出来了，所以保留，下面联合发文的代码，但是实际执行的时候进不到下面来的。
//    	 if(isunit && isunit.value=="true"){
//    	      if(!transformWordToPdf(newPdfIdSecond))
//    	      {
//    	        return true;
//    	      }
//    	 }
        //增加这个隐藏域主要是用来告诉服务器当前操作是否成功的执行了转PDF操作，如果是的话后台需要保存PDF相关的信息。
	document.getElementById("isConvertPdf").value="isConvertPdf";
	//document.getElementById("newPdfIdFirst").value=newPdfIdFirst;
    //	document.getElementById("newPdfIdSecond").value=newPdfIdSecond;
	//}
	return true;
}
function edocContentUnLoad()
{
	try{
		unLoadHtmlHandWrite();
	}catch(e){}
}

function superviseCheck(){
		var mId = document.getElementById("supervisorMemberId");
		var sDate = document.getElementById("superviseDate");
		if(mId!=null && sDate!=null){//首先判断有无督办时间和督办人员的元素
			if(mId.value == "" && sDate.value != ""){//如果选择了督办时间,而督办人员没有选,提示
				alert(v3x.getMessage("edocLang.edoc_supervise_select_member"));
				return false;
			}
			if(mId.value!= "" && sDate.value == ""){//如果选择了督办人员,而督办时间没有选,提示
				alert(v3x.getMessage("edocLang.edoc_supervise_select_date"));
				return false;
			}
			if(mId.value !="" && sDate.value !=""){
				supervised = true;  //如果督办时间和督办人员都设置了参数				
			}
		}
	}

function superviseRemindMode(){
		//暂时为在线
		//督办的提醒方式： 在线是第0位，短信是第1位，电邮是第2位 ， 分别用0,1来表示是否采用了此种提醒方式
		/*
		var online = document.getElementById("online");
		var mobile = document.getElementById("mobile");
		var email = document.getElementById("email");
		
		var primary = "0";
		var second = "0";
		var third = "0";
		
		if(online!=null && mobile!=null && email!=null){
		if(online.checked){
			primary = "1";
		}
		if(mobile.checked){
			second = "1";
		}
		if(email.checked){
			third = "1";
		}
		
		var remindMode = primary+second+third;
		*/
		if(document.getElementById("remindMode")){
			document.getElementById("remindMode").value = "100";//100为在线,010为手机短信,001为电邮,如此类推
		}
}

var isCancelZcdbTime=true; //是否取消或直接关闭暂存待办提醒时间窗口
function doZcdb(obj) {
	//暂存待办提醒时间设置
	openZcdbTime();
	if(isCancelZcdbTime){return ;}
	//copyContentIframePra2Suammry();
		//验证内部文号是否被占用
	if(contentIframe.isUpdateEdocForm){//修改了公文单
		if(!contentIframe.checkSerialNoExcludeSelf())return;
	}
	var theForm = obj.theform;
	if(!checkModifyingProcess(theForm.processId.value, theForm.summary_id.value)){
		return;
	}
	
	if(!contentIframe.saveEdocForm())
	{
	  return;
	}
	checkExistBody();
    if(!saveContent())
	{
	  return;
	}
	if(!contentIframe.saveHwData())
	{
	  return;
	}
  //debugger;
	superviseRemindMode(); //公文待办督办仍然有效
	//保存当前处理人所提交处理意见所带的附件 
	saveAttachment();		  
	//执行过"删除"和"插入"操作的时候，保存公文正文的附件。
	//if(hasUploadAtt || removeChanged){
   // 	saveContentAttachment();
	//}
	 
	if(contentIframe.checkUpdateHw()){				
	  try{
		  recordChangeWord(theForm.affair_id.value ,theForm.summary_id.value ,",wendanqianp",theForm.ajaxUserId.value);			
		}catch(e){}
	}
    //假如修改了附件，就保存附件，记录日志。发送消息
    //if(parent.detailMainFrame._updateAttachmentState){
	//	parent.detailMainFrame.updateAttachmentOnly();
    //}
	if(theForm.edocType.value == 2){
		saveCardInfo(theForm.edocType.value,theForm.summary_id.value);
	}
	
    theForm.action = genericURL + "?method=doZCDB";
    theForm.submit();
    
    document.getElementById("processButton").disabled = true;
    document.getElementById("zcdbButton").disabled = true;
}
//程炯 太原市政府项目 请示卡内容保存  2012-7-27
function saveCardInfo(edocType,summaryId){
	if(edocType == 2){
		var cardDiv = document.getElementById("cardDive");
		var cardform_input = document.getElementById("cardform_btn");
		if(cardDiv != null && cardDiv != ''&&cardDiv.hasChildNodes()){

		    url=encodeURIComponent(cardDiv.innerHTML); 
			url=encodeURIComponent(url); 
			$.post("/seeyon/edocForm.do?method=saveChangeCardInfo","cardDiv="+url+"&summaryId="+summaryId);	
		} 
	}
}
//程炯 太原市政府项目 删除请示卡内容  2012-7-27
function deleteCardInfo(edocType,summaryId){
	if(edocType == 2){
		$.post("/seeyon/edocForm.do?method=deleteChangeCardInfo","summaryId="+summaryId);
	}
}
/**
 * 暂存待办提醒时间窗口
 */
function openZcdbTime(){
	var url = edocURL + "?method=openZcdbTime" ;
	v3x.openWindow({
		url		: url,
		width	: 300,
		height	: 150,
		resizable	: "yes"
	});
}

function showAdvance() {
    var rv = v3x.openWindow({
        url: genericControllerURL + "collaboration/advance",
        width: "300",
        height: "280"
    });

    if (rv != null && (rv == "true" || rv)) {

    }
}


function selectUrger(elements) {
    if (!elements) {
        return;
    }

    document.getElementById("urgertext").value = getNamesString(elements);
    document.getElementById("urgerinput").innerHTML = getIdsInput(elements, "urger");
}

/**
 * 检查是否可以修改流程
 * 
 * @return true 可以， false 不可以，表示有其他人在修改流程
 */
function checkModifyingProcess(_processId, _summaryId){
	try{
    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "checkModifyingProcess", false);
    	requestCaller.addParameter(1, "String", _processId);
    	requestCaller.addParameter(2, "Long", _summaryId);
    	var ds = requestCaller.serviceRequest();
    	if(ds){
    		if(ds.startsWith("--NoSuchSummary--")){
    			alert(v3x.getMessage("edocLang.edoc_hasCancelOrStepback"));
    			return false;
    		}
    		alert(v3x.getMessage("collaborationLang.editing_process", ds));
    		return false;
	    }
    }
    catch(e){
    	alert(e.message)
    	return false;
    }
    
    return true;
}

/**
 * 判断流程是否已经被锁定，未被锁定则给该流程加上一个同步锁，为接下来的修改流程做准备
 * 
 * @param _processId
 * @param _summaryId
 * @return true 可以， false 不可以，表示有其他人在修改流程
 */
function checkModifyingProcessAndLock(_processId, _summaryId){
	try{
    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "colCheckAndupdateLock", false);
    	requestCaller.addParameter(1, "String", _processId);
    	requestCaller.addParameter(2, "Long", _summaryId);
    	var ds = requestCaller.serviceRequest();
    	if(ds != null && ds != ""){
    	    if(ds.startsWith("--NoSuchSummary--")){
    			alert(v3x.getMessage("edocLang.edoc_hasCancelOrStepback"));
    			return;
    		}
    		
    		alert(v3x.getMessage("collaborationLang.editing_process", ds));
    		return false;
	    }
	    else{
	    	return true;
	    }
    }
    catch(e){
    	alert(e.message)
    }
    
	return false;
}

/**
 * 修改完流程，解除流程同步锁
 */
function colDelLock(_processId, _summaryId){
	try{
    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "colDelLock", false,"GET",false);
    	requestCaller.addParameter(1, "String", _processId);
    	requestCaller.addParameter(2, "String", _summaryId);
    	if((arguments.length>2))
    	{
    		requestCaller.addParameter(3, "String", arguments[2]);	
    	}
    	requestCaller.serviceRequest();
    }catch(e){
    }
}

function checkIsCanBeRepealed(summaryId){
	var isCanBeRepealedFlag;
	try {
	  		var requestCaller = new XMLHttpRequestCaller(this, "edocManager", "checkIsCanBeRepealed", false);
	  		requestCaller.addParameter(1,'String',summaryId);
	  		isCanBeRepealedFlag = requestCaller.serviceRequest();
		  	}
	  	catch (ex1) {
	  		alert("Exception : " + ex1);
	  		return false;
	  	}
	return isCanBeRepealedFlag;
	
}
//检查是否可以发文后取回
function checkIsCanBeTakeBack(summaryId){
	var isCanBeRepealedFlag;
	try {
	  		var requestCaller = new XMLHttpRequestCaller(this, "edocManager", "checkIsCanBeTakeBack", false);
	  		requestCaller.addParameter(1,'String',summaryId);
	  		isCanBeRepealedFlag = requestCaller.serviceRequest();
		  	}
	  	catch (ex1) {
	  		alert("Exception : " + ex1);
	  		return false;
	  	}
	return isCanBeRepealedFlag;
	
}

/*
 * 撤销流程
 */
 
 function repealItems(fromPageType) {
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return;
    }

    var hasMoreElement = false;
    var len = id_checkbox.length;
    var countChecked = 0;
    var _processId = null;
    var summaryId;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            hasMoreElement = true;
            countChecked++;
            _processId = id_checkbox[i].processId;
            summaryId = id_checkbox[i].value;
        }
    }
    
    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertCancelItem"));
        return;
    }
    
    if(countChecked > 1){
    	alert(v3x.getMessage("edocLang.edoc_alertSelectCancelOnlyOne"));
        return;
    }

	if(!checkModifyingProcess(_processId, summaryId)){
		return;
	}
	var checkIsCanBeRepealedFlg = checkIsCanBeRepealed(summaryId);
    if("Y"!=checkIsCanBeRepealedFlg){
    	alert(checkIsCanBeRepealedFlg);
        return;
    }
	
    var rv = getA8Top().v3x.openWindow({
        url: genericControllerURL + "collaboration/repealCommentDialog",
        width: 400,
       	height: 300,
       	resizable: true
    });
    if(rv){
        disableButtons();
    	//var element = document.createElement("<INPUT TYPE=HIDDEN NAME='repealComment' value='" + rv + "' />");
        var element2 = document.createElement("input");
    	element2.setAttribute('type','hidden');
    	element2.setAttribute('name','repealComment');
    	element2.setAttribute('value',rv);
        theForm.appendChild(element2); 
        
        theForm.action = genericURL + "?method=repeal";
        theForm.docBack.value = "cancelColl";
        theForm.target = "tempIframe";
        theForm.method = "POST";
        theForm.submit();
    }
}
 

 /*
  * 撤销流程
  */
  
  function cancelBackEdoc(fromPageType) {
     var theForm = document.getElementsByName("listForm")[0];
     if (!theForm) {
         return false;
     }

     var id_checkbox = document.getElementsByName("id");
     if (!id_checkbox) {
         return;
     }

     var hasMoreElement = false;
     var len = id_checkbox.length;
     var countChecked = 0;
     var _processId = null;
     var summaryId;
     for (var i = 0; i < len; i++) {
         if (id_checkbox[i].checked) {
             hasMoreElement = true;
             countChecked++;
             _processId = id_checkbox[i].processId;
             summaryId = id_checkbox[i].value;
         }
     }
     
     if (!hasMoreElement) {
         alert(v3x.getMessage("edocLang.edoc_alertCancelItem"));
         return;
     }
     
     if(countChecked > 1){
     	alert(v3x.getMessage("edocLang.edoc_alertSelectCancelOnlyOne"));
         return;
     }

 	/*if(!checkModifyingProcess(_processId, summaryId)){
 		return;
 	}*/
 	var checkIsCanBeRepealedFlg = checkIsCanBeRepealed(summaryId);
     if("Y"!=checkIsCanBeRepealedFlg){
     	alert(checkIsCanBeRepealedFlg);
         return;
     }
 	
     var rv = getA8Top().v3x.openWindow({
         url: genericControllerURL + "collaboration/repealCommentDialog",
         width: 400,
        	height: 300,
        	resizable: true
     });
     if(rv){
         disableButtons();
     	//var element = document.createElement("<INPUT TYPE=HIDDEN NAME='repealComment' value='" + rv + "' />");
         var element2 = document.createElement("input");
     	element2.setAttribute('type','hidden');
     	element2.setAttribute('name','repealComment');
     	element2.setAttribute('value',rv);
         theForm.appendChild(element2); 
         
         theForm.action = genericURL + "?method=cancelBackEdoc";
         theForm.docBack.value = "cancelColl";
         theForm.target = "tempIframe";
         theForm.method = "POST";
         theForm.submit();
     }
 }
 
 //已发取回
 function sentTakeBack(){
	 	var theForm = document.getElementsByName("listForm")[0];
	    if (!theForm) {
	        return false;
	    }

	    var id_checkbox = document.getElementsByName("id");
	    if (!id_checkbox) {
	        return;
	    }
	    var hasMoreElement = false;
	    var len = id_checkbox.length;
	    var countChecked = 0;
	    var _processId = null;
	    var summaryId;
	    for (var i = 0; i < len; i++) {
	        if (id_checkbox[i].checked) {
	            hasMoreElement = true;
	            countChecked++;
	            _processId = id_checkbox[i].processId;
	            summaryId = id_checkbox[i].value;
	        }
	    }
	    
	    if(countChecked==0){
	    	alert(v3x.getMessage("edocLang.edoc_alertTakeBackItem"));
	    	return;
	    }
	    
	    if(countChecked>1){
	    	alert(v3x.getMessage("edocLang.edoc_alertSelectTakeBackOnlyOne"));
	    	return;
	    }

	    if (!window.confirm(v3x.getMessage("edocLang.edoc_confirmTakeBackItem"))) {
	    	return;
	    }
	   
        disableButtons();
    	//var element = document.createElement("<INPUT TYPE=HIDDEN NAME='repealComment' value='" + rv + "' />");
        
        theForm.action = genericURL + "?method=repeal&docBack=docBack";
        theForm.docBack.value = "docBack";
        theForm.target = "tempIframe";
        theForm.method = "POST";
        theForm.submit();

 }

 //打开发文，收文登记簿页面
 function openSendRegister(edocType){
	var url1 = "edocController.do?method=sendRegister&edocType="+edocType+"&ndate="+new Date();
	var retObj = v3x.openWindow({
     	url: url1,
     	FullScrean: 'yes',
     	dialogType : "modal"
	});
	if (retObj){
		window.location.reload(); 
	}
}
 
 
/*
 * 审批节点撤销流程
 */
function repealItem(fromPageType,summaryId) {
	var theForm = document.getElementById("theform");
    if (!theForm) {
        return false;
    }
    var opinionContent="";
    if(theForm.contentOP)	opinionContent=theForm.contentOP.value;
    var data = {
        page:"dealrepeal",
        id: [summaryId],
        content: opinionContent
    }
    var action = genericURL + "?method=repeal";
    
        var target = "showDiagramFrame";
    	//var method = "GET";
    	
    	//submitMap(data, genericURL+"?method=deletePeople","showDiagramFrame");
    	
	if(!checkModifyingProcessAndLock(theForm.processId.value, summaryId)){
		return;
	}

    if (window.confirm(v3x.getMessage("edocLang.edoc_confirmCancelItem"))) {
        submitMap(data, action,target);
        //submitMap(data, genericURL+"?method=deletePeople","");
    }
}

var isShowingDesigner = false;
function designWorkFlow(frameNames,isOnlyView) {
	frameNames = frameNames || "";
    isShowingDesigner = true;
    var onlyView = (isOnlyView == "true");
    var rv = getA8Top().v3x.openWindow({
        url: genericControllerURL + "collaboration/monitor&isShowButton=true&frameNames=" + frameNames+"&appName="+appName+ "&isOnlyView=" + onlyView,
        width: "860",
        height: "690",
        resizable: "no"
    });

    isShowingDesigner = false;
    if (rv != null) {

    }
    if(rv==true){processing=false;}
}

function newColl() {
    
}

/**
 * 另存模板
 */
function saveAsTemplete(type) {
	//检查form
    var theForm = document.getElementsByName("sendForm")[0];
    if (!theForm) {
        return;
    }
    //流程验证
    if(!hasWorkflow) {
    	alert(_("edocLang.edoc_alertSelectEdocWorkFlow"));
    	return;
    }
    
    //标题不验证
    var subjectObj = document.getElementById("my:subject");
    if(subjectObj) {
    	var subject = document.getElementById("subject");
    	if(!subject || subject==null) {
    		$(theForm).append("<input type='hidden' id='subject' name='subject' value='"+subjectObj.value+"' inputName='标题'/>");
    	    $(theForm).append("<input type='hidden' name='tembodyType' value=''/>");
    	    $(theForm).append("<input type='hidden' name='formtitle' value=''/>");
    	    subject = document.getElementById("subject");
    	} 
    }
    //打开保存模板界面
    var rv = v3x.openWindow({
        url: genericControllerURL + "collaboration/saveAsTemplate&hasWorkflow=" + hasWorkflow+"&edocType=1",
        height: 220,
        width: 350
    });
	
    if (!rv) {
        return;
    }
    
	var over = rv[0];
    var overId = rv[1];
    var type = rv[2];
    var templatename = rv[3];    
    
	if(over == 2){
		return;
	}
	//非纯文本，必须含流程
	if (type != "text") {
        if (!checkSelectWF()) {
            return;
        }
    }
	//模板
	if(type == "templete"){			
    	var atts = fileUploadAttachments.values();
		for(var i = 0; i < atts.size(); i++) {
			var att = atts.get(i) ;
			if(att.type == '1' || att.type == '3' || att.type == '4'){
				if(att.subReference != ""){
					att.extSubReference = att.subReference ;
				}else{
					att.extSubReference = att.extSubReference ;
				}				
			}
		} 		
	    cloneAllAttachments();	  	
		saveAttachment();
    }
	if(type != "workflow"){
        var bodyType = document.getElementById("bodyType").value;
        if (bodyType != "HTML") {
        	saveOffice();
        }		
	}
	isFormSumit = true;

    theForm.target = "personalTempleteIframe";
    try{adjustReadFormForSubmit();}catch(e){}
    
    var edocType = document.getElementById("edocType").value;
    var categoryId = 2;
    if(edocType == 0) {categoryId=2;}
    else if(edocType==1) {categoryId=3;}
    else if(edocType==2) {categoryId=5;}
    if(document.getElementById("isSys")) {
    	theForm.isSys.value = 0;
    	theForm.categoryId.value = categoryId;
    	theForm.categoryType.value = categoryId;
    	theForm.templatename.value = templatename;
    } else {
    	$(theForm).append("<input type='hidden' name='isSys' id='isSys' value='0'/>");
        $(theForm).append("<input type='hidden' name='categoryId' value='"+categoryId+"'/>");
        $(theForm).append("<input type='hidden' name='categoryType' value='"+categoryId+"'/>");
        $(theForm).append("<input type='hidden' name='type' value='"+type+"'/>");
        $(theForm).append("<input type='hidden' name='templatename' value='"+templatename+"'/>");
    }
    theForm.id.value = overId;
    theForm.action = "/seeyon/edocTempleteController.do?method=saveTemplete";
    theForm.submit();
    getA8Top().startProc('');
    theForm.id.value = theForm.summaryId.value; 
}

function _setWorkFlow(_caseProcessXML,_workflowInfo)
{
          hasDiagram = true;
          hasWorkflow = true;
          isFromTemplate = true;
          document.getElementsByName("sendForm")[0].process_desc_by.value = 'xml';
          document.getElementsByName("sendForm")[0].process_xml.value = _caseProcessXML;
          if (workflowInfo) {
        	document.getElementsByName("sendForm")[0].workflowInfo.value = _workflowInfo;
    	  }
    	  document.getElementsByName("sendForm")[0].workflowInfo.disabled=true;
    	  showMode=0;
}

/**
 * 
 */
function openTemplete(templeteCategrory) {
    //window.open(genericControllerURL + "collaboration/templete/index&categoryType="+templeteCategrory);
    //return;
    var comm=document.getElementById("comm").value;
    var orgAccountId=document.getElementById("orgAccountId").value;
    var _url;
    if(comm=="register" || comm=="distribute") 
    	_url=genericControllerURL + "collaboration/templete/index&categoryType="+templeteCategrory+"&subType=isExchangeDocToRegist&accountId="+orgAccountId;
    else
    	_url=genericControllerURL + "collaboration/templete/index&categoryType="+templeteCategrory;
   
    if(v3x.getBrowserFlag('OpenDivWindow')==true){
	    var rv = getA8Top().v3x.openWindow({
	        url : _url,
	        height : "600",
	        width : "800"
	    });
	    if (rv) {
	        var templeteType=rv[0];
	        var workflow = "";
	        var bodyContent = "";
	        var xml="";
	        var xslt="";
	        var edocFormId="";
	        var exchangeId=document.sendForm.exchangeId.value;
	        var registerId=document.sendForm.registerId.value;
	        var distributeEdocId=document.sendForm.distributeEdocId.value;
	        var backBoxToEdit = document.sendForm.backBoxToEdit.value;
	        var edocType=sendForm.edocType.value;
	        isFormSumit = true;
	        var fromStateParam="";
	       	var exchangeRegister="";
	        var comm=document.sendForm.comm.value;
	        if(comm=="transmitSend")
	        {
	         	fromStateParam="&fromState=transmitSend";
	        }
	        
	        if(exchangeId!="") {
	        	var strEdocId=document.getElementById("strEdocId").value;
	        	exchangeRegister+="&strEdocId="+strEdocId+"&exchangeId="+exchangeId;
	        }
	        
	        if((registerId!="" && registerId!="-1") || distributeEdocId!="") {
	        	if(registerId!="" && registerId!="-1") {
	 	        	exchangeRegister += "&registerId="+registerId;
	 	        }
	        	if(distributeEdocId!="" && distributeEdocId!="")  {
		        	exchangeRegister += "&distributeEdocId="+distributeEdocId;
		        }
	        	exchangeRegister += "&register="+comm;
	        }
	       
	        if(backBoxToEdit!="") {
	        	var backBoxToEdit=document.getElementById("backBoxToEdit").value;
	        	exchangeRegister+="&backBoxToEdit="+backBoxToEdit;
	        }
	        
	        self.location.href=genericURL+"?method=newEdoc&edocType="+edocType+"&templeteId="+rv[8]+fromStateParam+exchangeRegister;    
	    }
    }else{
		var win = v3x.openDialog({
	    	id:"templateIpad",
	    	title:v3x.getMessage("collaborationLang.find_template"),
	    	url :_url,
	    	width: 800,
	        height: 500,
	        //isDrag:false,
	        //targetWindow:getA8Top(),
	        //fromWindow:window,
	        type:'window',
	        //relativeElement:obj,
	        buttons:[{
				id:'btn121',
	            text: v3x.getMessage("collaborationLang.submit"),
	            handler: function(){    	        	
	        		var rv = win.getReturnValue();
	        		if(rv){
	        	        var templeteType=rv[0];
	        	        var workflow = "";
	        	        var bodyContent = "";
	        	        var xml="";
	        	        var xslt="";
	        	        var edocFormId="";
	        	        var exchangeId=document.sendForm.exchangeId.value;
	        	
	        	          var edocType=sendForm.edocType.value;
	        	          isFormSumit = true;
	        	          var fromStateParam="";
	        	       	  var exchangeRegister="";
	        	          var comm=document.sendForm.comm.value;
	        	          if(comm=="transmitSend")
	        	          {
	        	          	fromStateParam="&fromState=transmitSend";
	        	          }
	        	          if(exchangeId!=""){
	        	          	var strEdocId=document.getElementById("strEdocId").value;
	        	          	exchangeRegister="&strEdocId="+strEdocId+"&register="+comm+"&exchangeId="+exchangeId;
	        	          }
	        	          self.location.href=genericURL+"?method=newEdoc&edocType="+edocType+"&templeteId="+rv[8]+fromStateParam+exchangeRegister; 
	        		}
	        		win.close();
            }
	            
	        }, {
				id:'btn211',
	            text: v3x.getMessage("collaborationLang.cancel"),
	            handler: function(){
	        	win.close();
	            }
	        }]
	    });
    	
    }
}


function getElementLeft(element){//获得某元素在网页中的绝对向左位置
	var actualLeft = element.offsetLeft;
	var current = element.offsetParent;

	while (current !== null){
		actualLeft += current.offsetLeft;
		current = current.offsetParent;
	}
	return actualLeft;
}


function getElementTop(element){//获得某元素在网页中的绝对顶部位置
	var actualTop = element.offsetTop;
	var current = element.offsetParent;

	while (current !== null){
		actualTop += current.offsetTop;
		current = current.offsetParent;
	}
	return actualTop;
}



function advanceViews(flag) {
    var processAdvanceDIVObj = document.getElementById("processAdvanceDIV");
    var processAdvanceDivIframe = document.getElementById("processAdvanceDivIframe");
    
    if(flag == null){
    	clickClose = false;
    }
    if ((flag || processAdvanceDIVObj.style.display == "none") && !clickClose) {
		processAdvanceDIVObj.style.display = "";
		if(processAdvanceDivIframe){
			var tempheight = processAdvanceDIVObj.clientHeight;
			processAdvanceDivIframe.style.height = tempheight+"px";
			processAdvanceDivIframe.style.display = "";
		}
		//document.getElementById("processAdvance").innerHTML = "&gt;&gt;&nbsp;&nbsp;"+_('collaborationLang.advance');
		var processAdvance =  document.getElementById("processAdvance");
		
		var eleLeft = getElementLeft(processAdvance);
		var eleTop = getElementTop(processAdvance);
		var bodyWidth = document.body.clientWidth;
		var width = 100;
		if(bodyWidth - eleLeft < width){
			processAdvanceDIVObj.style.left = bodyWidth - width;
			processAdvanceDivIframe.style.left = bodyWidth - width;
		}else{
			processAdvanceDIVObj.style.left = eleLeft + 20;
		    processAdvanceDivIframe.style.left = eleLeft + 20;
		}
	    processAdvanceDIVObj.style.top = eleTop + 10;
	    processAdvanceDivIframe.style.top = eleTop + 10;
	}
	else{
		processAdvanceDIVObj.style.display = "none";
		if(processAdvanceDivIframe)processAdvanceDivIframe.style.display = "none";
		//document.getElementById("processAdvance").innerHTML = "&lt;&lt;&nbsp;&nbsp;"+_('collaborationLang.advance');
	}
}
//显示高级菜单一栏
function showAdvanceViews(flag) {
		var moreOperationDiv = document.getElementById("moreOperationDiv");
		if(!moreOperationDiv.show || moreOperationDiv.show=="false") {
			moreOperationDiv.style.display = "";
			moreOperationDiv.show = "true";
		} else {
			moreOperationDiv.style.display = "none";
			moreOperationDiv.show = "false";
		}
			
}

function closeAdvance(){
	 var processAdvanceDIVObj = document.getElementById("processAdvanceDIV");
	 var processAdvanceDivIframe = document.getElementById("processAdvanceDivIframe");
	 if(processAdvanceDIVObj){
	 	clickClose = true;
	 	processAdvanceDIVObj.style.display = "none";
	 	if(processAdvanceDivIframe)processAdvanceDivIframe.style.display = "none";
	 }
}
function openNewEditWin()
{
	if(canUpdateContent){contentUpdate=true;}
	var isFormTemplete = "isFromTemplete";
	//来自公文模板打开正文
	popupContentWin(isFormTemplete);
}

/**
 * 修改正文
 */
function modifyBody(summaryId,hasSign) {   
  var bodyType = document.getElementById("bodyType").value;
  if(bodyType=="HTML")
  {
  	contentUpdate=true;
  	popupContentWin();
  }else if(bodyType=="Pdf"){
       popupContentWin();
        var tempContentUpdate=ModifyContent(hasSign);
        if(contentUpdate==false)
             contentUpdate=tempContentUpdate;
        
        if(changeWord == false) 
             changeWord = tempContentUpdate;
  }else
  {
    //检查正文区域是否装载完成  
    if(!hasLoadOfficeFrameComplete()) return false;
  	//是否将公文单中的内容自动更新到公文正文中
  	//1.修改正文 2.书签>0，3.给出套红提示。
  	checkOpenState();
  	if(getBookmarksCount()>0){
  		if(confirm(_("edocLang.edoc_refreshContentAuto"))){
  			refreshOfficeLable();
  		}
  	}
  	popupContentWin();
  	//先签章,后修改正文,有问题
  	//if(contentUpdate==true){return;}  	
    var tempContentUpdate=ModifyContent(hasSign);
	if(contentUpdate==false){
		contentUpdate=tempContentUpdate;
	}
    if(changeWord == false) 
     changeWord = tempContentUpdate;
  }  
}

function openSignature()
{
  var bodyType = document.getElementById("bodyType").value;
  if(bodyType=="HTML")
  {
  	alert(_("edocLang.edoc_htmlnofuntion"));
  }else if(bodyType=="Pdf"){
  	popupContentWin();
  }
  else
  {
  	//联合发文套多次正文后，是否进行了保存
  	var isUniteSend=document.getElementById("isUniteSend").value;
  	if(isUniteSend=="true")
  	{
  		var curContentNum= sendForm.currContentNum.value;
  		var curRecordId=contentOfficeId.get(curContentNum,null);
  		if(curRecordId==null)
  		{//刚刚进行了正文套红，正文还没有保存
  			if(window.confirm(_("edocLang.edoc_contentNoSave"))==false){return;}
  			var newRecordId=checkExistBody();
  	  		askUserSave(false);
  			contentOfficeId.put(curContentNum,newRecordId);
  		}
  	}  	
    WebOpenSignature();
  }  
  contentUpdate=true;
  changeSignature = true ;
}

function modifyBodySave() {
    if (!_saveOffice()) {
        return;
    }

    disableButton("save");
    disableButton("cancel");

    theForm.submit();
}

function doEndModifyBodySave() {
    window.returnValue = "true";
    window.close();
}

/**
 * 新建 显示发起人附言区域
 */
function showNoteArea() {
		  if(document.getElementById("noteAreaTd")!=undefined&&document.getElementById("noteAreaTd")!=null)
	  {
	  document.getElementById("noteAreaTd").width = "180px";

    document.getElementById('noteAreaTable').style.display = "";
    var _noteMinDiv = document.getElementById('noteMinDiv');
    _noteMinDiv.style.display = "none";
    _noteMinDiv.style.height = "0px";
	  }

}

function hiddenNoteArea() {
	  if(document.getElementById("noteAreaTd")!=undefined&&document.getElementById("noteAreaTd")!=null)
	  {
	  document.getElementById("noteAreaTd").width = "45px";

    document.getElementById('noteAreaTable').style.display = "none";
    var _noteMinDiv = document.getElementById('noteMinDiv');
    _noteMinDiv.style.display = "";
    _noteMinDiv.style.height = "100%";
	  }

}

/**
 * 解析流程XML，返回字符串 Meber|1321234
 */
function getWFInfoFromXML(xmlString) {
    if (!xmlString) {
        return "";
    }

    var xmlDom = null;
    try {
        xmlDom = new ActiveXObject("MSXML2.DOMDocument");
    }
    catch (e) {
        return "";
    }

    try {
        xmlDom.loadXML(xmlString);

        var root = xmlDom.documentElement;
        if (!root) {
            return "";
        }

        var process = root.selectNodes("process");
        if (!process) {
            return "";
        }

        var nodes = process[0].selectNodes("node");
        if (!nodes || nodes.length < 1) {
            return "";
        }

        var partyIds = [];

        for (var i = 0; i < nodes.length; i++) {
            var node = nodes[i];

            var actors = node.selectNodes("actor");

            if (!actors || actors.length < 1) {
                continue;
            }

            for (var j = 0; j < actors.length; j++) {
                var actor = actors[j];
                var partyId = actor.getAttribute("partyId");
                var partyType = actor.getAttribute("partyType");

                if (partyId && !isNaN(partyId)) {
                    partyIds[partyIds.length] = partyType + "|" + partyId;
                }
            }
        }

        return partyIds.join(",");
    } catch(e) {
    }

    return "";
}

function doForward() {
    var theForm = document.getElementsByName("sendForm")[0];
    if (!theForm) {
        return false;
    }

    if (!hasWorkflow) {
        alert(v3x.getMessage("edocLang.edoc_selectWorkflow"));
        selectPeopleFun_forward()
        return false;
    }

    if (!checkForm(theForm)) {
        return false;
    }

    saveAttachment();

    theForm.b1.disabled = true;
    theForm.b2.disabled = true;
    theForm.submit();
}

function addNote(_isNoteAddOrReply, opinionId) {
    reply(opinionId);

    //发起人增加附言
    if (_isNoteAddOrReply == 'addnote') {
        var theForm = document.getElementsByName("repform")[0];

        document.getElementById("isHiddenDiv").style.display = "none";
        theForm.isNoteAddOrReply.value = _isNoteAddOrReply;
    }
}

function quoteDocumentEdoc(appType) {
    var atts = v3x.openWindow({
        url: genericURL + "?method=showList4QuoteFrame&appType="+appType,
        height: 600,
        width: 800
    });
    if (atts) {
		deleteAllAttachment(2);
        for (var i = 0; i < atts.length; i++) {
            var att = atts[i]

            //addAttachment(type, filename, mimeType, createDate, size, fileUrl, canDelete, needClone, description)
            addAttachment(att.type, att.filename, att.mimeType, att.createDate, att.size, att.fileUrl, true, false, att.description, null, att.mimeType + ".gif",att.reference, att.category)
        }
    }
}
function jumpState(workstate,edocType)
{
  var url=edocContorller;
  if(workstate=="darft"){url+="?method=edocFrame&from=listWaitSend&edocType="+edocType;}
  else if(workstate=="sended"){url+="?method=edocFrame&from=listSent&edocType="+edocType;}
  else if(workstate=="pending"){url+="?method=edocFrame&from=listPending&edocType="+edocType;}
  else if(workstate=="done"){url+="?method=edocFrame&from=listDone&edocType="+edocType;}
  else if(workstate=="waitRegister"){url+="?method=edocFrame&from=listRegisterPending&edocType="+edocType;}
  else if(workstate=="doing"){url+="?method=edocFrame&from=listZcdb&edocType="+edocType;}
  else if(workstate=="finish"){url+="?method=edocFrame&from=listFinish&edocType="+edocType;}
  parent.location.href=url;  
}
function quoteDocumentOK() {
    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return null;
    }
    var atts = [];

    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        var c = id_checkbox[i];

        if (c.checked) {
            var type = "2";
            var filename = c.getAttribute("subject");
            var mimeType = c.getAttribute("documentType");
            var createDate = "0000-00-00 00:00:00";
            var fileUrl = c.getAttribute("url");
            var description = c.getAttribute("url");

            //function Attachment(id, reference, subReference, category, type, filename, mimeType, createDate, size, fileUrl, description, needClone)
            atts[atts.length] = new Attachment('', '', '', '', type, filename, mimeType, createDate, '0', fileUrl, description);
        }
    }

    if (!atts || atts.length < 1) {
        alert(getA8Top().v3x.getMessage('edocLang.edoc_alertQuoteItem'));
        return;
    }

    parent.window.returnValue = atts;
    parent.window.close();
}
function newEdoc(edocType)
{
	//lijl添加获取checkbox的第一个值-------------Start
	var oCheckbox = document.getElementsByName("id");
	var count =0;
	var id="";
    for(var i=0;i<oCheckbox.length;i++)
    {
    	if(oCheckbox[i].checked){
    		id=oCheckbox[i].value;
    		count++;
    	}
    }
    //lijl添加获取checkbox的第一个值-------------End
    if(count==0){
		alert(_("edocLang.edoc_alertDontSelectMulti"));
		return;
    }else if(count>1){
		alert(_("edocLang.edoc_alertOnlyOneSelectMultiToFenfa"));
		return;
	}else{
		location.href=genericURL+"?method=newEdoc&edocType="+edocType+"&id="+id;
	}
	

}


//转办文弹出提示窗口--
function showForwardWD(){
	var objcts = document.getElementsByName("id");
	var checked="";
	var checkedId=0;
	var count =0;
	for (var i = 0; i < objcts.length; i++) {
		if(objcts[i].checked) {
			checked='1';
			count++;
			checkedId = objcts[i].value;
		}
	}
	if(checked != '1'){
		alert(_("edocLang.batch_select_readToDone"));
	    return ;
	}else if(count>1){
		alert(_("edocLang.batch_select_onlyforwardsend"));
	    return ;
	}else{
		document.getElementById("edocId").value= checkedId;
		var _url= genericURL+"?method=forwordOption";
		var re= v3x.openWindow({
			url: _url,
			height : 160,
			width  : 300
		  });
		if(re=='True'){
			//隐藏域的form表单
			document.checkElementForm.submit();
		}
	}
}

//转发文弹出提示窗口
function showForwardWDOne(){
	var objcts = document.getElementsByName("id");
	var checked="";
	var checkedId=0;
	var count =0;
	var checkOption="";
	var newContactReceive = "";
	var recieveId = "";
	for (var i = 0; i < objcts.length; i++) {
		if(objcts[i].checked) {
			checked='1';
			count++;
			checkedId = objcts[i].getAttribute("edocId");
			//待登记关联发文时，关联id用签收id
			recieveId = objcts[i].getAttribute("recieveId");
			
		}
	}
	if(checked != '1'){
		alert(_("edocLang.batch_select_forwardsend"));
	    return ;
	}else if(count>1){
		alert(_("edocLang.batch_select_onlyOne_forwardsend"));
	    return ;
	}else{
		//document.getElementById("edocId").value= checkedId;
		var _url= genericURL+"?method=forwordOption";
		var re= v3x.openWindow({
			url: _url,
			height : 206,
			width  : 300
		  });
		if(re=='True'){
			//隐藏域的form表单
			var newContactReceive = document.getElementById("newContactReceive");
			 checkOption = document.getElementById("forwardCheckOption").value;
			 if(newContactReceive != null){
				 newContactReceive = newContactReceive.value;
				 parent.parent.location.href="edocController.do?method=listIndex&from=newEdoc&edocType=0&comm=forwordtosend&edocId="+checkedId+"&recieveId="+recieveId+"&checkOption="+checkOption+"&newContactReceive="+newContactReceive;
			 }else{
				 parent.parent.location.href="edocController.do?method=listIndex&from=newEdoc&edocType=0&comm=forwordtosend&edocId="+checkedId+"&checkOption="+checkOption;
			 }
		}
	}
}


//转发文弹出提示窗口
function showForwardWDTwo2(listType){
	var objcts = document.getElementsByName("id");
	var checked="";
    var checkOption="";
	var checkedId=0;
	var count =0;
	var newContactReceive = "";
	for (var i = 0; i < objcts.length; i++) {
		if(objcts[i].checked) {
			checked='1';
			count++;
			checkedId = objcts[i].registerId;
		} 
	}
	if(checked != '1'){
		alert(_("edocLang.batch_select_forwardsend"));
	    return ;
	}else if(count>1){
		alert(_("edocLang.batch_select_onlyOne_forwardsend"));
	    return ;
	}else{
		var _url= genericURL+"?method=forwordOption";
		var re= v3x.openWindow({
			url: _url, 
			height : 206,
			width  : 300
		  });
		if(re=='True'){
		//隐藏域的form表单
			var newContactReceive = document.getElementById("newContactReceive");
			 checkOption = document.getElementById("forwardCheckOption").value;
			 if(newContactReceive !=null){
				 newContactReceive = newContactReceive.value;
				 var url = "edocController.do?method=listIndex&from=newEdoc&edocType=0&comm=forwordtosend&edocId="+checkedId+"&checkOption="+checkOption+"&newContactReceive="+newContactReceive;
				 if(listType == 'registered'){
					 url += "&forwordType=registered";
				 }else if(listType == 'waitSent'){
					 url += "&forwordType=waitSent";
				 }
				 parent.parent.location.href=url;
			 }else{
				 parent.parent.location.href="edocController.do?method=listIndex&from=newEdoc&edocType=0&comm=forwordtosend&edocId="+checkedId+"&checkOption="+checkOption; 
			 }
		}
	}
} 

//转发文弹出提示窗口
function showForwardWDTwo(listType){
	var objcts = document.getElementsByName("id");
	var checked="";
    var checkOption="";
	var checkedId=0;
	var count =0;
	var newContactReceive = "";
	for (var i = 0; i < objcts.length; i++) {
		if(objcts[i].checked) {
			checked='1';
			count++;
			checkedId = objcts[i].value;
		} 
	}
	if(checked != '1'){
		alert(_("edocLang.batch_select_forwardsend"));
	    return ;
	}else if(count>1){
		alert(_("edocLang.batch_select_onlyOne_forwardsend"));
	    return ;
	}else{
		var _url= genericURL+"?method=forwordOption";
		var re= v3x.openWindow({
			url: _url, 
			height : 206,
			width  : 300
		  });
		if(re=='True'){
		//隐藏域的form表单
			var newContactReceive = document.getElementById("newContactReceive");
			 checkOption = document.getElementById("forwardCheckOption").value;
			 if(newContactReceive !=null){
				 newContactReceive = newContactReceive.value;
				 var url = "edocController.do?method=listIndex&from=newEdoc&edocType=0&comm=forwordtosend&edocId="+checkedId+"&checkOption="+checkOption+"&newContactReceive="+newContactReceive;
				 if(listType == 'registered'){
					 url += "&forwordType=registered";
				 }else if(listType == 'waitSent'){
					 url += "&forwordType=waitSent";
				 }
				 parent.parent.location.href=url;
			 }else{
				 parent.parent.location.href="edocController.do?method=listIndex&from=newEdoc&edocType=0&comm=forwordtosend&edocId="+checkedId+"&checkOption="+checkOption; 
			 }
		}
	}
} 

//阅转办弹出提示窗口
function showReadToDoneWD(){
	var objcts = document.getElementsByName("id");
	var checked="";
	var checkedId=0;
	var count=0;
	for (var i = 0; i < objcts.length; i++) {
		if(objcts[i].checked) {
			checked='1';
			count++;
			checkedId = objcts[i].value;
		}
	}
	if(checked != '1'){
	alert(_("edocLang.batch_select_readToDone"));
	   return ;
    }else if(count>1){
	alert(_("edocLang.batch_select_onlyforwardsend"));
	    return ;
	}else{
		document.getElementById("edocId").value= checkedId;
	    document.getElementById("checkOption").value='3';
		document.checkElementForm.submit();
	}
}
//得到弹出窗口的选择值，并赋给父窗口变量
function checkForwdForm(){
	var val= document.getElementById("optionValue").value;
    var newContactReceive = document.getElementsByName("newContactReceive");
    var newContactReceiveVal = "";
	   for(var i = 0; i < newContactReceive.length; i++){
		   if(newContactReceive[i].checked){
			   newContactReceiveVal = newContactReceiveVal+ newContactReceive[i].value;
			   newContactReceiveVal = newContactReceiveVal + ",";
			   }
		   }
	   if(newContactReceiveVal.substring(newContactReceiveVal.length-1,newContactReceiveVal.length)==","){
			     newContactReceiveVal = newContactReceiveVal.substring(0,newContactReceiveVal.length-1);
	   }
    //
	var _parent = window.opener;
	if(_parent == null){
		_parent = window.dialogArguments;
	}
	_parent.document.getElementById("forwardCheckOption").value= val;
	if(newContactReceiveVal !=""){
		_parent.document.getElementById("newContactReceive").value= newContactReceiveVal;
	}
	window.returnValue="True";
	window.close();
}

function changeEdocForm(selectObj)
{
  //var formId=selectObj.options[selectObj.selectedIndex].value;
  //getEdocFormModel(formId);  
  document.sendForm.action=collaborationCanstant.changeEdocFormURL;
  var tempCanUpdateContent=null;
  try{tempCanUpdateContent=_canUpdateContent;}catch(e){}
  //if(tempCanUpdateContent==false)
  //{
  	try{adjustReadFormForSubmit();}catch(e){}
 // }
  var retData=ajaxFormSubmit(document.sendForm);
  var xmlObj=document.getElementById("xml");
  //yangzd 转移数据中的特殊字符
  temp=new String(retData.get("xml"));
  temp = temp.replace(/&amp;/gi,"&");
	//temp = temp.replace(/&lt;/gi,"<");
	//temp = temp.replace(/&gt;/gi,">");
	temp = temp.replace(/<br>/gi,"");
	temp = temp.replace(/&#039;/gi,"\'");
	temp = temp.replace(/&#034;/gi,"\"");
	temp = temp.replace(/&apos;/gi,"\'");
  xmlObj.value=temp;
//  xmlObj.value=retData.get("xml");
//yangzd
  var xlsObj=document.getElementById("xslt");
  xlsObj.value=retData.get("xslt");edocFormDisplay(); 
}
function getEdocFormModel(formId)
{
  try {
		var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocFormManager", "getEdocFormModel",false);
		requestCaller.addParameter(1, "long", formId);
		requestCaller.addParameter(2, "long", actorId);
		var ds = requestCaller.serviceRequest();
		var xmlObj=document.getElementById("xml");
		xmlObj.value=ds.get("xml");
		var xlsObj=document.getElementById("xslt");
		xlsObj.value=ds.get("xslt");
		edocFormDisplay();
	}
	catch (ex1) {
		alert("Exception : " + (ex1.number & 0xFFFF)+ex1.description);
	}
}

//newEdoc.jsp页面使用
function dealPopupContentWinWhenDraft(contentNum){
	if(canUpdateContent){contentUpdate=true;}
	dealPopupContentWin(contentNum);
}
function dealPopupContentWin()
{

	try{
	if(window.document.readyState!="complete") {return false;}
	var bodyType = document.getElementById("bodyType").value;
  	if(bodyType=="HTML")
  	{  	
  		popupContentWin();
  	}else if(bodyType=='Pdf'){
  	    popupContentWin();
  	}
  	else
  	{	
  		var contentNum = document.getElementById("currContentNum").value;
  		var forwordtosend=document.getElementById("forwordtosend").value;//办文转起草标识
  		var newOfficeId=contentOfficeId.get(contentNum,null);
  		if(newOfficeId && (forwordtosend != '1')){
	  		if(newOfficeId!=getOfficeOcxCurVerRecordID())
	  		{
	  			//askUserSave(true);
	  			setOfficeOcxRecordID(newOfficeId);
	  			//为保证印章有效，控件FileName参数属性必须和改章的时候的参数一样，所以复制一份后要想保证原来印章有效，这个参数不能变化
	  			document.getElementById("contentNameId").value=contentOfficeId.get("0",null);
	  			//theform.currContentNum.value=contentNum;
	  			contentUpdate=false;
	  		}
  		}
  		popupContentWin();
  	}
	}catch(e){}
}
/**
 * 点击页面按钮的时候加载office插件，但是不全屏，嵌入到页面中
 * @return
 */
function LazyloadOffice(contentNum){
	try{
		if(window.document.readyState!="complete") {return false;}
		var bodyType = document.getElementById("bodyType").value;
		//加载office插件
		if(bodyType!="HTML" && bodyType!='Pdf'){
	  		var newOfficeId=contentOfficeId.get(contentNum,null);
	  		if(newOfficeId){
		  		if(newOfficeId!=getOfficeOcxCurVerRecordID())
		  		{
		  			askUserSave(true);
		  			setOfficeOcxRecordID(newOfficeId);
		  			//为保证印章有效，控件FileName参数属性必须和改章的时候的参数一样，所以复制一份后要想保证原来印章有效，这个参数不能变化
		  			document.getElementById("contentNameId").value=contentOfficeId.get("0",null);
		  			theform.currContentNum.value=contentNum;
		  			contentUpdate=false;
		  		}
	  		}
	  		document.getElementById("edocContentDiv").style.display="block";
	  		checkOpenState();
	  		fullSize();
		}else if(bodyType == 'Pdf'){
			checkPDFOpenState();
			pdfFullSize();
		}
	}catch(e){}
}
//正文修改后，提示用户是否修改
function askUserSaveOnly()
{
	if(contentUpdate==true)
	{
		return window.confirm(_("edocLang.edoc_contentConfirmSave"));				
	}
	else
	{
		return false;
	}
}
//正文修改后，提示用户是否修改
function askUserSave(isAsk)
{
	var isSave=true;
	if(contentUpdate==true)
	{
		if(isAsk)
		{
			isSave=window.confirm(_("edocLang.edoc_contentConfirmSave"));
		}
		if(isSave)
		{
			if(saveOffice()==false)
  	  		{
  	  			alert(_("edocLang.edoc_contentSaveFalse"));
  	  			return false;
  	  		}
  	  		contentUpdate=false;						
		}		
	}
	return true;
}
/**
弹出正文窗口
**/
function popupContentWin()
{
	if(window.document.readyState!="complete") {return false;}
  var bodyType = document.getElementById("bodyType").value;
  if(bodyType=="HTML")
  { 
  	var isFromTemplete = false;	
    for(var i = 0; i < arguments.length; i++) {
				var tempArg = arguments[i];
				if(tempArg == 'isFromTemplete'){
					isFromTemplete = true;
					break;
				}
			}
  	var tempUrl=fullEditorURL;
	if(isFromTemplete){
		//来自公文模板，不检查正文是否被并发修改；
	  	if(contentUpdate==false){tempUrl+="&canEdit=false";}
		else{tempUrl+="&canEdit=true";}	
	}
	else{
		//非公文模板，检查正文是否被并发修改；
	  	if(contentUpdate==false || (checkConcurrentModifyForHtmlContent(summaryId) && (summaryId!=-1 && summaryId!=0))){tempUrl+="&canEdit=false";}
	  	else{tempUrl+="&canEdit=true";}	
	}
	
  	if(typeof(officecanPrint)!="undefined" && officecanPrint!=null)
	{
  		tempUrl+="&canPrint="+officecanPrint;
	}
	else
	{
		tempUrl+="&canPrint=true";
	}
    var rv = v3x.openWindow({url: tempUrl,workSpace: 'yes'});  
    if(document.getElementById("content")!=null && (typeof(oFCKeditor) != "undefined"))
    {
      if(rv==null){return;}
      oFCKeditor.SetContent(rv);
      oFCKeditor.remove();//提交的时候不在拷贝编辑区域到输入text;
    }
    else
    {
      if(rv==null){return;}
      document.getElementById("edoc-contentText").innerHTML=rv;
    }
  }else if(bodyType=="Pdf"){
    pdfFullSize();
  }else{
    fullSize();
  }
}
function getHtmlContent()
{
  var str="";
  if(document.getElementById("content")!=null && (typeof(oFCKeditor) != "undefined"))
  {
    str=oFCKeditor.GetContent();
  }
  else
  {//浏览状态,正文放到Div里面了
    str=document.getElementById("edoc-contentText").innerHTML;
  }
  return str;
}
//处理时保存修改的公文单
function saveEdocForm()
{
  if(document.sendForm.elements["my:subject"].value.trim()=="")	
  {
    		alert(_("edocLang.edoc_inputSubject"));
    		/*
    		if(document.sendForm.elements("my:subject").disabled==true)
    		{
    			alert(_("edocLang.edoc_alertSetPerm"));
    			return false;
    		}
    		*/
    		try{document.sendForm.elements["my:subject"].focus();}catch(e){}
    		return false;
  }
  if(isUpdateEdocForm==false){return true;}
  document.sendForm.action=collaborationCanstant.updateEdocFormURL;
  if(validFieldData()==false){return false;}
  
  // 确保发文单位被提交
  if(document.getElementById('my:send_unit'))
	document.getElementById('my:send_unit').setAttribute('canSubmit','true');
  var retData=ajaxFormSubmit(document.sendForm);
  var ret;
  if(retData.indexOf("result=true")>=0){
  	ret = true;
  }else if(retData.indexOf("result=historyMarkExist:")>=0){
  	//签报时判断文号是否重复
  	var position = retData.indexOf(":");
  	alert(retData.substring(position+1));
  	ret = false;
  }else{
  	ret = false;
  }
  return ret;
}
//处理时保存正文
function saveContent()
{ 
	var ajaxStr = "" ;//记录的是修改的类型的记录
	var affair_IdValue = document.getElementById("affair_id") ;
	var summary_IdValue = document.getElementById("summary_id");
	var ajaxUserId = document.getElementById("ajaxUserId");
	var redFormObj = document.getElementById("redForm");	
	if(redFormObj)  {
		var redFormValue = redFormObj.value ;	
		if(redFormValue == "true" && affair_IdValue && summary_IdValue){			
			ajaxStr = ajaxStr + ",taohongwendan" ;					   		
		  }		
	}

  if(contentUpdate==false){
	 submitToRecord();	
  	 return true;
  }  
  var bodyType = document.getElementById("bodyType").value;  
  if(bodyType=="HTML")
  {
      try {
		var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "updateHtmlBody",false);
		var bodyContentId=document.getElementById("bodyContentId").value;
		requestCaller.addParameter(1, "long", bodyContentId);
		requestCaller.addParameter(2, "String",getHtmlContent());
		var ds = requestCaller.serviceRequest();	
		ajaxStr = ajaxStr + ",contentUpdate" ;
		submitToRecord();		
		return (ds=="true");
	}
	catch (ex1) {
		alert("Exception : " + (ex1.number & 0xFFFF)+ex1.description);
		return false;
	}            
  }else if(bodyType=="Pdf"){
      savePdf();
      if(contentUpdate) {
		if(changeWord){			
		    ajaxStr = ajaxStr + ",contentUpdate" ;			
		}			
	  }
      submitToRecord();	
  }else
  { 
  	/**
	 * 记录正文被修改的记录
	 */
	if(contentUpdate) {
		if(changeWord){			
		    ajaxStr = ajaxStr + ",contentUpdate" ;			
		}			
	}
	/**
	 * 记录正文套红
	 */
	if(hasTaohong) {
	    var redContentValue = theform.redContent;
	    if(redContentValue && redContentValue.value == "true") 
		    ajaxStr = ajaxStr + ",taohong" ;		    			
	}
	/**
	 * 签章
	 */
	if(changeSignature) {		
	    ajaxStr = ajaxStr + ",qianzhang" ;						
	} 
	
	submitToRecord();	
    if(saveOffice()==false)
    {
      return false;
    }
  }
  
	// AJax记录操作日志
    function submitToRecord(){
        if(ajaxStr != ""  && affair_IdValue && summary_IdValue && ajaxUserId) {
    		recordChangeWord(affair_IdValue.value ,summary_IdValue.value ,ajaxStr, ajaxUserId.value)
    		ajaxStr = "" ;
        }	
    }
  return true;
}
/**
* AJax记录流程日志
*/
function recordChangeWord(affair_IdValue ,summary_IdValue ,ajaxStr,userId) {
	if(affair_IdValue == "" && summary_IdValue == "" && ajaxStr == "") 
	  return ;
		try{
	    	if(affair_IdValue && summary_IdValue) {	    
		    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "recoidChangeWord", false);
		    	requestCaller.addParameter(1, "String", affair_IdValue);
		    	requestCaller.addParameter(2, "String", summary_IdValue);	
		    	requestCaller.addParameter(3, "String", ajaxStr) ;
		    	requestCaller.addParameter(4, "String", userId) ;
		    	requestCaller.serviceRequest() ;		    		
	    	}	
		}catch(e){
		}	  
}

//调用模板确定后的回调函数
function refTemplete() {
    var id = getParameter("id");
    var rv = [];
    rv[0]=templeteType;
	if(templeteType == 'text')
	{
	    rv[1] = document.getElementById("xslt").value;
        rv[2] = document.getElementById("xml").value;
        rv[3] = edocFormId;
        rv[4] = document.getElementById("bodyType").value;
        if(rv[4]=="HTML")
        {
	      rv[5]=document.getElementById("edoc-contentText").innerHTML;
	    }
	    else
	    {
	      rv[5]=fileId;
	      rv[6]=createDate;
	    }
	    rv[7]=id;	    
	}
	else if(templeteType == 'workflow')
	{
	    rv[1] = caseProcessXML;
        rv[2] = workflowInfo;
        rv[3]=id;
        //返回分支条件        
        rv[11]=branchs;
        rv[12]=keys;
        rv[13]=team;
        rv[14]=secondpost;
        
	}
	else if(templeteType == 'templete')
	{
	    rv[1]=id;
	    rv[2] = caseProcessXML;
        rv[3] = workflowInfo;
	    /*rv[1] = caseProcessXML;
        rv[2] = workflowInfo;
        rv[3] = edocFormId;
        rv[4] = document.getElementById("xslt").value;
        rv[5] = document.getElementById("xml").value;
	    rv[6]=document.getElementById("edoc-contentText").innerHTML;
	    */
	    //返回分支条件        
        rv[11]=branchs;
        rv[12]=keys;
        rv[13]=team;
        rv[14]=secondpost;
        
        //返回督办信息
        rv[15]=supervisorId;
        rv[16]=supervisors;
        rv[17]=unCancelledVisor;
        rv[18]=sVisorsFromTemplate;
        rv[19]=awakeDate;
        rv[20]=superviseTitle;
	}
	
	rv[8]=id;

    top.window.returnValue = rv;
    top.close();
}
//调用模板确定后的回调函数
function refTempleteIpad() {
    var id = getParameter("id");
    var rv = [];
    rv[0]=templeteType;
	if(templeteType == 'text')
	{
	    rv[1] = document.getElementById("xslt").value;
        rv[2] = document.getElementById("xml").value;
        rv[3] = edocFormId;
        rv[4] = document.getElementById("bodyType").value;
        if(rv[4]=="HTML")
        {
	      rv[5]=document.getElementById("edoc-contentText").innerHTML;
	    }
	    else
	    {
	      rv[5]=fileId;
	      rv[6]=createDate;
	    }
	    rv[7]=id;	    
	}
	else if(templeteType == 'workflow')
	{
	    rv[1] = caseProcessXML;
        rv[2] = workflowInfo;
        rv[3]=id;
        //返回分支条件        
        rv[11]=branchs;
        rv[12]=keys;
        rv[13]=team;
        rv[14]=secondpost;
        
	}
	else if(templeteType == 'templete')
	{
	    rv[1]=id;
	    rv[2] = caseProcessXML;
        rv[3] = workflowInfo;
	    /*rv[1] = caseProcessXML;
        rv[2] = workflowInfo;
        rv[3] = edocFormId;
        rv[4] = document.getElementById("xslt").value;
        rv[5] = document.getElementById("xml").value;
	    rv[6]=document.getElementById("edoc-contentText").innerHTML;
	    */
	    //返回分支条件        
        rv[11]=branchs;
        rv[12]=keys;
        rv[13]=team;
        rv[14]=secondpost;
        
        //返回督办信息
        rv[15]=supervisorId;
        rv[16]=supervisors;
        rv[17]=unCancelledVisor;
        rv[18]=sVisorsFromTemplate;
        rv[19]=awakeDate;
        rv[20]=superviseTitle;
	}
	
	rv[8]=id;

    return rv;
}
//清空所有的affairId的value;
function clearAffairIdValue(){
	var affairIds = document.getElementsByName("affairId");
	try{
		if(affairIds){
			for(var i = 0;i<affairIds.length;i++){
				affairIds[i].value = '';
			}
		}
	}catch(e){
		
	}
}
//公文归档
function pigeonholeForEdoc(pageType,edocType)
{	
	//请空affairId的值，防止上次产生的affairId的值传递到了后台。
	clearAffairIdValue();
	var appName = document.getElementById("appName").value; 
	var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }
    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return true;
    }
    var hasMoreElement = false;
    //是否直接弹出选择归档路径的对话框，当所有的都没有归档路径的时候就直接弹出，否则就不直接弹出。提交到后台
    var isSelectRedirectly = true ;
    var len = id_checkbox.length;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
            hasMoreElement = true;
            break;
        }
    }
    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertPigeonholeItem"));
        return true;
    }
    //已办列表，判断是否有归档权限，已发列表不需要判断
    if(pageType == 'finish'){ 
    	var affairIds="";
        for (var i = 0; i < len; i++) {
            if (id_checkbox[i].checked) {
              if(affairIds==""){
                affairIds=id_checkbox[i].affairId; 
              }else {
                affairIds+=","+id_checkbox[i].affairId; 
              }
            }
        }
    	var ret=checkHasAclNodePolicyOperation(affairIds,'Archive' );
	    if(ret != 'ok'){
	    	var arr=ret.split("&");
	        alert(v3x.getMessage("edocLang.edoc_alertnotaclaccpigeonhole",arr[0]));
	        for (var i = 0; i < len; i++) {
	        	 if (id_checkbox[i].checked) {
	        		 if(arr[1].indexOf(id_checkbox[i].affairId)!= -1 ){
	        			 id_checkbox[i].checked = false; 
	        		 }
	        	 }
	        }
	        return;
	    }
    }
   
    var _affairId = "";
	theForm.action = collaborationCanstant.pigeonholeActionURL;
	disableButtons();
    var hasArchive="";//已经归档
//    var notFinished = "";//流程未结束
	for (var i = 0; i < id_checkbox.length; i++) {
	    var checkbox = id_checkbox[i];
	    if (!checkbox.checked)
		   	continue;
		
	    //判断是否已经归档，并且归档文件夹没有被删除。如果归档文件夹被删除了还要运行归档。
	    var docResourceIsExist = '';
	    if(checkbox.hasArchive=="true" || checkbox.archiveId != "" ){
	    	docResourceIsExist = checkPigholeDocResourceIsExist(checkbox.archiveId);
	    }
		if(checkbox.hasArchive=="true"){
		    if(docResourceIsExist=='true') {
			    hasArchive+="《"+checkbox.subject+"》\r\n";
			    checkbox.checked = false;
			    continue;
		    }
		}
		//设置了预先归档，并且预归档文件夹存在，就提交到后台
		if(checkbox.archiveId != "" && docResourceIsExist == 'true'){
			isSelectRedirectly = false;
		}
		var affairId = checkbox.getAttribute("affairId");
		//var element = document.createElement("<INPUT TYPE=HIDDEN NAME=affairId value='" + affairId + "' />"); ff不支持
		var element = document.createElement("INPUT"); 
		element.name = "affairId"; 
		element.value= affairId ;
		element.type="HIDDEN";
		
		theForm.appendChild(element);
	}

	if(hasArchive != ""){
	    alert(_("edocLang.edoc_alertHasPigeonhole",hasArchive));
	    return;
	}
	
	if(isSelectRedirectly){
		doPigeonhole('new',appName,'listDone','');
		var archiveId = document.getElementById('archiveId').value;
		if(archiveId == '') return;
	}
	
	//var element = document.createElement("<INPUT TYPE=HIDDEN NAME=pageType value='" + pageType + "' />");
	var element = document.createElement("INPUT"); 
	element.name = "pageType"; 
	element.value= pageType ;
	element.type="HIDDEN";
	theForm.appendChild(element);
	//var element = document.createElement("<INPUT TYPE=HIDDEN NAME=edocType value='" + edocType + "' />");
	var element = document.createElement("INPUT"); 
	element.name = "edocType"; 
	element.value= edocType ;
	element.type="HIDDEN";
	theForm.appendChild(element);	
	theForm.target = "tempIframe";
	theForm.method = "POST";
	theForm.submit();
	try{getA8Top().startProc('')}catch(e){};
	return true;
}
/**
 *判断当前事项是否能指定的操作 。
 * @param affairIds  : 个人事项ID
 * @param operationName ： 操作名(如：DepartPigeonhole)
 * @return 当传入的事项都有权限的时候，返回为空值，当传入的某些事项没有指定操作的权限的时候，返回没有权限的事项的标题。
 */
function checkHasAclNodePolicyOperation(affairIds,operationName){
    var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "checkHasAclNodePolicyOperation",false);
    requestCaller.addParameter(1, "String", affairIds);  
    requestCaller.addParameter(2, "String", operationName);  
    var ds = requestCaller.serviceRequest();
    return ds;
}
function checkPigholeDocResourceIsExist(archiveId){
 	var requestCaller = new XMLHttpRequestCaller(this, "ajaxDocHierarchyManager", "docResourceExist",false);
    requestCaller.addParameter(1, "Long", archiveId);  
    var ds = requestCaller.serviceRequest();
    return ds;
}
function listDepartPigeonhole(appName){
    //getA8Top().startProc('');
    var theForm = document.getElementsByName("listForm")[0];
    if (!theForm) {
        return false;
    }

    var id_checkbox = document.getElementsByName("id");
    if (!id_checkbox) {
        return true;
    }
    
    var summaryIds="";
    var affairIds="";
    var len = id_checkbox.length;
    var hasMoreElement = false;
    for (var i = 0; i < len; i++) {
        if (id_checkbox[i].checked) {
          hasMoreElement = true;
          
          if(summaryIds==""){
               summaryIds=id_checkbox[i].value;
           }else{
               summaryIds+=","+id_checkbox[i].value;
           }
           
          if(affairIds==""){
            affairIds=id_checkbox[i].affairId; 
          }else {
            affairIds+=","+id_checkbox[i].affairId; 
          }
          
        }
    }
    if (!hasMoreElement) {
        alert(v3x.getMessage("edocLang.edoc_alertPigeonholeItem"));
        return true;
    }
    
   //判断是否有部门归档的权限
    var ret=checkHasAclNodePolicyOperation(affairIds,'DepartPigeonhole');
    if(ret != 'ok'){
    	var arr=ret.split("&");
        alert(v3x.getMessage("edocLang.edoc_alertnotacldeppigeonhole",arr[0]));
        for (var i = 0; i < len; i++) {
        	 if (id_checkbox[i].checked) {
        		 if(arr[1].indexOf(id_checkbox[i].affairId)!= -1 ){
        			 id_checkbox[i].checked = false; 
        		 }
        	 }
        }
        return;
    }
   
    var archiveIds=pigeonhole(appName,summaryIds);
	if(archiveIds == "cancel"){
		return;
	}
	if(archiveIds == "" || archiveIds == "failure"){
		alert(v3x.getMessage("edocLang.edoc_alertPigeonholeItemFailure"));	   
	}
	else
	{
		try{
		    var ajaxUserId = document.getElementById("ajaxUserId");    			    	
			if(summaryIds && affairIds && ajaxUserId) {
				recordChangeWord(affairIds ,summaryIds ,"depPinghole",ajaxUserId.value)
			}			    	 							    				    	
		}catch(e){}			
		alert(v3x.getMessage("edocLang.edoc_alertPigeonholeItemSucceed"));		   
		window.location.href = window.location.href;
	}
}

function DepartPigeonhole(appName,summaryId)
{
	var archiveIds=pigeonhole(appName,summaryId);
	if(archiveIds == "cancel"){
		return;
	}
	if(archiveIds == "" || archiveIds == "failure"){
		alert(v3x.getMessage("edocLang.edoc_alertPigeonholeItemFailure"));	   
	}
	else
	{
			try{
				var affair_IdValue = document.getElementById("affair_id") ;
			    var summary_IdValue = document.getElementById("summary_id") ;	
			    var ajaxUserId = document.getElementById("ajaxUserId");    			    	
				if(affair_IdValue && summary_IdValue && ajaxUserId) {
					recordChangeWord(affair_IdValue.value ,summary_IdValue.value ,"depPinghole",ajaxUserId.value)
				}			    	 							    				    	
			}catch(e){}			
		alert(v3x.getMessage("edocLang.edoc_alertPigeonholeItemSucceed"));		    			
	}
}

function timeValidate(begin,end){
	if(new Date(begin.replace(/-/g,"/")) > new Date(end.replace(/-/g,"/"))){
		alert("开始时间不能大于结束时间!");
		return false;
	}	
	return true;
}

//双击编辑待发公文单
function editWaitSend(summaryId,affairId,type)
{
	var url = genericURL+"?method=newEdoc&summaryId="+summaryId+"&from=WaitSend"+"&affairId="+affairId;	
	//从退稿箱中到 拟文编辑页面
	if(type == 1){
		url += "&backBoxToEdit=true";
	}
	location.href = url;
}

//点击编辑图标编辑待发公文单
function editFromWaitSend(type, from)
{
	if(from == undefined || from == null || from == "") {
		from = "WaitSend";
	}
	try{
		var id_checkbox = document.getElementsByName("id");
	    if (!id_checkbox) {
	        return;
	    }
	    var count = validateCheckbox("id");
	    if(count == 1){
	    	for(var i=0; i<id_checkbox.length; i++){
				var idCheckBox = id_checkbox[i];
				var substate=""; //待发子状态 1：草稿，2：回退 3：撤销
				if(idCheckBox.checked){
					var summaryId = idCheckBox.value;
					var affairId =  idCheckBox.getAttribute("affairId");
		        	substate = id_checkbox[i].substate;
		        	
		        	//草稿在没有拟文权限的情况下，不再允许编辑
		        	if(isEdocCreateRole==false && substate==1){
		        		alert(v3x.getMessage("edocLang.alert_not_edoccreate"));
		    			return;
		        	}
					var isSendBackBox = document.getElementById("isSendBackBox");
					
					var url = genericURL+"?method=newEdoc&summaryId="+summaryId+"&from="+from+"&affairId="+affairId+(isSendBackBox && isSendBackBox.value?"&isSendBackBox="+isSendBackBox.value:"");
					//从退稿箱中到 拟文编辑页面
					if(type == 1){
						url += "&backBoxToEdit=true";
					}
					url += "&comm="+document.getElementById("comm");
					location.href= url;
				}
			}
	    }
	    else if(count == 0){
	    	alert(v3x.getMessage("edocLang.edoc_alertSelectEditItem"));
	        return;
	    }
	    else{
	    	alert(v3x.getMessage("edocLang.edoc_alertDontSelectMulti"));
	 		return;
	    }
	}catch(e){
	}
}

/***************公文单控制部分开始*******************/
//*初始化时全部初始化为只读状态,不根据xml的权限进行控制*//
function initReadSeeyonForm(s,x){
	//var initStr = "http://128.2.2.84:8080/seeyon/form.do?method=creatformxml&";
	//initStr = initStr + "formOperation=" + formOperation;
	
    //var str = init(initStr);
	//alert(str);
	var str = s;
	var xslStart = str.indexOf("&&&&&&&  xsl_start  &&&&&&&&");
	var dataStart = str.indexOf("&&&&&&&&  data_start  &&&&&&&&");
	var inputStart = str.indexOf("&&&&&&&&  input_start  &&&&&&&&");
	
	if(xslStart == -1)
			throw  "没有找到xsl";
	if(dataStart == -1)
			throw "没有找到data";
	if(inputStart == -1)
			throw "没有找到input";
	var xsl = str.slice(xslStart + 28, dataStart);
	var data = str.slice(dataStart + 30, inputStart);
	var finput = str.slice(inputStart + 31);
	
	//替换&字符
  //var reg=/&/g;
  //data=data.replace(reg, "&amp;");
  
  
  var html = document.getElementById("html");
  var fnow=transformNode(data, x); 
  //infopath设置了自动换行，转化为html的时候会自动添加下面这个可编辑的属性，导致意见元素可编辑，所以需要替换掉。
  fnow= fnow.replace(/contentEditable=\"true\"/g,"");
  html.innerHTML = fnow;
  initReadHtml(finput);
  initJSObject(data);
  try{setOpinionSpandefaultHeight();}catch(e){}
}

//取到area并进行替换

function initReadHtml(aInput){
	Init_Image();
	//document.onclick = SeeyonForm_BuildDocClickHandler('common');
	var fFiledList = paseFormatXML(getXmlContent(aInput))
	
	
	
	convertReadHtml(fFiledList);
	
	var repeatTable = new Seeyonform_rtable();
	repeatTable.change();
	
	var reSection = new Seeyonform_rsection();
	reSection.change();
	  
}

function convertReadHtml(aFieldList){
	var field;
	var fAreas;
	for(var i = 0; i < aFieldList.length; i++){
		 field = aFieldList[i];
		 fAreas = field.findArea(field.fieldName);
		 
		 if(fAreas != 0){
    		  for(var j =0; j < fAreas.length;j++){
    		      //312sp1 bug 31615 将内部文号独立出来，不根据开关“是否允许修改外来文登记”来控制。后续进行根细化的处理。
    		      if(field.fieldName=="my:serial_no" && typeof(currentPage)!="undefined" && currentPage=="newEdoc"){
    		         if(field.access == "edit" || field.access == null ){
    					field.change(fAreas[j]);
    					if(firstCanEditElementId==""){firstCanEditElementId=field.fieldName;}
    					isIncludeCanUpdateElement=true;
    		         }else{
    		            field.browse(fAreas[j]);	
    		         }
    		     }else{
    				field.browse(fAreas[j]);							 				
    	 		}
    		  }
		 }else{
		 		//throw "页面没有名为"+ field.fieldName +"的span元素";
		 } 
  }
}


//文号修改标志
var edocMarkUpd=false;
//修改文单标记
var edocUpdateForm=false;

function addSelectOption(obj,value,dis)
{
	if(obj==null || value==""){return;}
	var i,len=obj.options.length;
	for(i=0;i<len;i++)
	{
		if(obj.options[i].value==value)
		{
			obj.options[i].selected=true;
			return;	
		}
	}
	var opt=document.createElement("OPTION");
	obj.options.add(opt);
	opt.value=value;
	opt.text=dis;
	opt.selected=true;
}


// 在多人执行时，判断是否有人修改正文。
function checkAndLockEdocEditForm(summaryId)
{
 var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocSummaryManager", "editObjectState",false);
  requestCaller.addParameter(1, "String", summaryId);  
  var ds = requestCaller.serviceRequest();

  if(ds.get("curEditState")=="true")
  {  
  	  	canUpdateWendan=false;  
  			alert(_("edocLang.edoc_cannotedit"));
  			return true;
  }
  //新建文档，不需要更新
  if(ds.get("lastUpdateTime")==null){return false;}  
  return false;
}

// 解锁，让别人可以修改文单
function unlockEdocEditForm(summaryId)
{
  var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocSummaryManager", "deleteUpdateObj",false,"GET",false);
  requestCaller.addParameter(1, "String", summaryId);  
	if((arguments.length>1))
	{
		requestCaller.addParameter(2, "String", arguments[1]);	
	}  
  requestCaller.serviceRequest();	
}
function UpdateEdocForm(summaryId)
{	
	parent.showPrecessAreaTd('edocform');
	// 判断是否有其他用户在修改文单
	if(checkAndLockEdocEditForm(summaryId)) return;
		//已经是文号修改状态
	if(edocUpdateForm){return;}

	var edocMark1="";
	var edocMarkDis1="";
	var edocMark2="";
	var edocMarkDis2="";
	//检查文号是否修改,避免修改文单后修改文号内容丢失
	if(edocMarkUpd)
	{
		var obj=document.getElementById("my:doc_mark");
		if(obj!=null && obj.tagName=="SELECT")
		{
			edocMark1=obj.options[obj.selectedIndex].value;
			edocMarkDis1=obj.options[obj.selectedIndex].text;
		}
		obj=document.getElementById("my:doc_mark2");
		if(obj!=null && obj.tagName=="SELECT")
		{
			edocMark2=obj.options[obj.selectedIndex].value;
			edocMarkDis2=obj.options[obj.selectedIndex].text;
		}
	}
	//保存手写签批信息，如果修改
	if(checkUpdateHw())
	{
		if(window.confirm(_("edocLang.edoc_confirmSaveHw")))
		{
			saveHwData();
		}
	}
			
      		var xml = document.getElementById("xml");
			var xsl = document.getElementById("xslt");
    		initSeeyonForm(xml.value,xsl.value);
    		
    		//重新生成公文单后，重新显示意见，手写内容
    		initSpans();
    		dispOpinions(opinions,sendOpinionStr);
    		initHandWrite();
    		substituteLogo(logoURL);    		
    		
    		if(isIncludeCanUpdateElement==false)
    		{
    			alert(_("edocLang.edoc_alertNoAccessUpdateEdocForm"));
    			return;
    		}
    		setObjEvent();
    		
			if(edocMarkUpd)
			{
				var obj=document.getElementById("my:doc_mark");
				if(obj!=null && obj.tagName=="SELECT")
				{
					addSelectOption(obj,edocMark1,edocMarkDis1);
				}
				obj=document.getElementById("my:doc_mark2");
				if(obj!=null && obj.tagName=="SELECT")
				{
					addSelectOption(obj,edocMark2,edocMarkDis2);
				}				
			}
    		
    		try{
   			if(firstCanEditElementId!="")
    			{
    			  var firstEditObj=document.getElementById(firstCanEditElementId);
    			  if(firstEditObj!=null)
    			  {    			  	
    			  	firstEditObj.focus();
    			  }
    			}
    		}catch(e)	
    		{		
    		}
    		isUpdateEdocForm=true;
    		//记录日志的时候不能区别出是修改了文单还是仅仅修改了文号。加此变量就是为了区别这个 BUG30034
    		var isOnlyModifyWordNo=document.getElementById("isOnlyModifyWordNo");
    		if(isOnlyModifyWordNo)isOnlyModifyWordNo.value="false";
    		edocUpdateForm=true;
    		return;
}

function setWordNoEdit(wordObj)
{
	var i;
	var jsObj=null;
	var divObj=null;
	if(wordObj.disabled==true || (wordObj.tableName!="SELECT" && wordObj.readOnly==true))
	{
		for(i=0;i<fieldInputListArray.length;i++)
		{			
			if(fieldInputListArray[i].fieldName==wordObj.name)
			{
				jsObj=fieldInputListArray[i];
				break;
			}
		}			
		if(jsObj!=null)
		{	
			jsObj.change(wordObj);		
			addEditWordNoImage(document.getElementById(wordObj.id));
		}
	}
}
/**
 *
 * @param obj
 * @return
 */
function getInputJsObject(obj){
	var jsObj = null;
	for(i=0;i<fieldInputListArray.length;i++)
	{			
		if(fieldInputListArray[i].fieldName==obj.name)
		{
			jsObj=fieldInputListArray[i];
			break;
		}
	}
	return jsObj;
}
function setSerialNoEdit(wordObj)
{
	var i;
	var jsObj=null;
	if(wordObj.disabled==true || (wordObj.tableName!="SELECT" && wordObj.readOnly==true))
	{
		jsObj = getInputJsObject(wordObj);
		if(jsObj!=null)
		{	
			jsObj.change(wordObj);
			if(_isTemplete!=true    //不是模板
					&& personInput=='true'  //允许手写
					&& typeof(isBoundSerialNo)!="undefined" && isBoundSerialNo !="true")//如果是调用模板。模板没有绑定内部文号
			
				addEditSerialNoImage(document.getElementById(wordObj.id));
		}
	}
}
/** 点击修改文号小图片跳转
* 33469 修改方案：(320)
*1、当页面只有公文文号，没有内部文号的时候就采用以前的方式，即弹出断号选择框的方式
*2、当页面即有公文文号又有内部文号的时候，则不弹出选择框，直接在文单中置成可以修改的形式。让用户点击图标
*/
function WordNoChange(objid)
{	
	if(!(typeof(currentPage)!='undefined' && currentPage == 'newEdoc')){
		//不是拟文页面点文号修改先执行页面跳转
		parent.showPrecessAreaTd("edocform");
	}
	var _obj;
	var selDocmark="my:doc_mark"; //给选择文号页面传递的参数，用来确定是第一套文号还是第二套文号。
	
	var templeteIdValue = "";
	var templeteId = document.getElementById("templeteId");
	if(templeteId) 	templeteIdValue = templeteId.value;

	if(objid==null)
	{
		_obj = document.getElementById("my:doc_mark");	
		if(_obj==null) {
		    _obj=document.getElementById("my:doc_mark2");	
		    selDocmark="my:doc_mark2";
		}
	}
	else
	{
		_obj = document.getElementById(objid);
		selDocmark=objid;
	}
	var serialNoObj = document.getElementById("my:serial_no");
	var docMarkObj = document.getElementById("my:doc_mark");
	var docMark2Obj = document.getElementById("my:doc_mark2");
	if(docMarkObj==null && docMark2Obj==null&& serialNoObj == null)
	{
		alert(_("edocLang.edoc_form_noDocMark"));
		return;
	}

	var type = document.getElementById("edocType");
	if(type != null && type.value=="1")
	{//收文，直接录入文号，不提供断号选择功能
		_obj.readOnly=false;
		_obj.disabled=false;
		_obj.focus();
		if(!objid){ //修改文号的时候不是点图标
			if(serialNoObj != null){
				setSerialNoEdit(serialNoObj);
			}
		}
		isUpdateEdocForm = true;
		return;
	}
	//判断页面是否有两个文号
	var twoDocmark=objid==null && (document.getElementById("my:doc_mark")!=null && document.getElementById("my:doc_mark2")!=null);
	var orgAccountId=document.getElementById("orgAccountId");
	var _orgAccountId="";
	if(orgAccountId)_orgAccountId=orgAccountId.value;
	
	if(serialNoObj == null){
		if(_obj != null) {
			openMarkChooseWindow(twoDocmark,selDocmark,_orgAccountId,templeteIdValue);
		}
	}else{  //有内部文号的时候不弹出选文号的界面。
		if(!objid){
			if(docMarkObj!=null)setWordNoEdit(docMarkObj);
			if(docMark2Obj!=null)setWordNoEdit(docMark2Obj);
			if(serialNoObj != null)setSerialNoEdit(serialNoObj);
		}else{
			if(_obj.name == "my:serial_no"){
				setSerialNoEdit(_obj);
			}else{
				openMarkChooseWindow(twoDocmark,selDocmark,_orgAccountId,templeteIdValue);
			}
		}
	}
	return;
}
function openMarkChooseWindow(twoDocmark,selDocmark,_orgAccountId,templeteIdValue){
	var receivedObj = v3x.openWindow({
		url: edocMarkURL+"?method=docMarkChooseEntry"+"&twoDocmark="+twoDocmark+"&selDocmark="+selDocmark
			+"&orgAccountId="+_orgAccountId+"&templeteId="+templeteIdValue,
		width:"450",
		resizable : "no",
		height:"380"
	});
	
	if(receivedObj != undefined){
		_obj = document.getElementById(receivedObj[2]);			
		setWordNoEdit(_obj);
		_obj = document.getElementById(receivedObj[2]);			
		for (var i = 0; i < _obj.options.length; i++) {
			var a = _obj.options[i].value;
			if (a == receivedObj[0]) {
				_obj.options[i].selected = true;
				return;
			}
		}
		var option = document.createElement("OPTION");
		option.value = receivedObj[0];
		option.text = receivedObj[1];
		_obj.options.add(option);
		option.selected = true;
		isUpdateEdocForm = true;
		edocMarkUpd=true;
	}
}
//弹出内部文号录入界面。
function SerialNoChange()
{
	var _obj= document.getElementById("my:serial_no");	

	//判断页面上是否存在内部文号
	if(_obj==null)
	{
		alert(_("edocLang.edoc_form_noSerialNo"));
		return;
	}
	if(_obj != null) {		
		var receivedObj = v3x.openWindow({
			url: edocMarkURL+"?method=serialNoInputEntry",
			width:"350",
			resizable : "no",
			height:"200"
		});

		if(receivedObj != undefined){	
			_obj = document.getElementById(receivedObj[2]);			
			setWordNoEdit(_obj);
			for (var i = 0; i < _obj.options.length; i++) {
				var a = _obj.options[i].value;
				if (a == receivedObj[0]) {
					_obj.options[i].selected = true;
					return;
				}
			}
			var option = document.createElement("OPTION");
			option.value = receivedObj[0];
			option.text = receivedObj[1];
			_obj.options.add(option);
			option.selected = true;
			isUpdateEdocForm = true;
			edocMarkUpd=true;
		}
	}		   
	return;
}
function initSpans()
{	
	var i,key;	
	var spanObjs=document.getElementsByTagName("span");
	opinionSpans=new Properties();
	for(i=0;i<spanObjs.length;i++)
	{		
		key=spanObjs[i].getAttribute("xd:binding");
		if(key!=null)
		{		
			//记录处理意见录入框的初始化大小，确定手写签批对话框大小;
			spanObjs[i].initWidth=spanObjs[i].style.width;
			spanObjs[i].initHeight=spanObjs[i].style.height;
			opinionSpans.put(key,spanObjs[i]);			
		}
	}	
}

function extendData(name, value){
	this.name = name;
	this.value = value;
}
var extendArray = new Array();

/*
 * 处理处理意见和处理人字体大小一致
 */
function changeFontsize(opinion,spanObj){
	try{
		
		if(spanObj!=null&&spanObj!=undefined){
			if(spanObj.style.fontSize!=null&&spanObj.style.fontSize!="")
			{
				opinion = opinion.replace(new RegExp("<span",'gm'),"<span style='font-Size:"+spanObj.style.fontSize+";'");
			}
		}
		return opinion;
	}catch(e){}
}

/*显示公文处理意见*/
function dispOpinions(opinions,senderOpinion)
{
try{	
	var i;
	//if((opinions==null || opinions.length<=0) && (senderOpinion==null || senderOpinion=="")){return;}		
	var otherOpinion="";
	var spanObj;
	var isboundSender = false;
	if(opinionSpans==null){initSpans();}
	for(i=0;i<opinions.length;i++)
	{
		if(opinions[i][0] =="niwen" || opinions[i][0] == 'dengji' ){isboundSender = true;}
		spanObj=opinionSpans.get("my:"+opinions[i][0],null);
		opinions[i][1]=changeFontsize(opinions[i][1],spanObj);
		if(spanObj==null||spanObj==undefined)
		{
			if(otherOpinion!=""){otherOpinion+="<br>";}
			otherOpinion+=opinions[i][1];
		}
		else
		{	
			spanObj.innerHTML=opinions[i][1];
		//	spanObj.title=spanObj.innerText;
			spanObj.style.height="auto"||"100%";
			spanObj.style.border="0px";
			spanObj.contentEditable="false";
			spanObj.style.whiteSpace = "normal";
			//spanObj.style.overflowY ="auto";
			extendArray[extendArray.length] = new extendData("my:"+opinions[i][0], spanObj.innerText);
		}
	}
	spanObj=opinionSpans.get("my:otherOpinion",null);
//	if(spanObj!=null)
//	{
//		spanObj.innerHTML=otherOpinion;
//		//20090909guoss修改，后台中将没有匹配成功的都放入了otherOpinion中。
//		//try{spanObj.innerHTML=opinions[opinions.length-1][1];}catch(e){}
//		spanObj.style.height="100%";
//		spanObj.style.whiteSpace = "normal";
//		spanObj.contentEditable="false";
//		spanObj.style.border="0px";		
//	}
	//else
	//{//公文单上面，未找到显示处理意见的位置，显示到公文单后面的div中
		if(otherOpinion!="" && spanObj == null)
		{
			spanObj=document.getElementById("displayOtherOpinions");
			if(spanObj!=null)
			{
				spanObj.innerHTML=otherOpinion;
				spanObj.style.visibility="visible";
				spanObj.style.height="100%";
				spanObj.style.whiteSpace = "normal";
				spanObj.contentEditable="false";
				spanObj.style.border="0px";
			}
		}
	//}
	
	//设置发起人意见
	spanObj=opinionSpans.get("my:niwen",null);
	if(spanObj==null){spanObj=opinionSpans.get("my:dengji",null);}
		//当有登记意见和拟文意见，则为登记意见（实际的情况是不出现登记和拟文意见同时出现的情况）
	if(opinionSpans.get("my:niwen",null)!=null&&opinionSpans.get("my:dengji",null)!=null){
		spanObj=opinionSpans.get("my:dengji",null);
	}
	if(spanObj!=null && senderOpinion!=null && senderOpinion!="")
	{
		//spanObj.innerHTML=senderOpinion;
		//spanObj.style.height="100%";
		//spanObj.style.whiteSpace = "normal";
		//公文单上面有意见显示位置时，隐藏公文单下面的意见
		spanObj=document.getElementById("displaySenderOpinoinDiv");
		if(spanObj!=null && isboundSender ){spanObj.innerHTML="";}
	}
	if(senderOpinion=="")
	{//没有发起意见,或者发起意见意见绑定到其它显示位置;
		spanObj=document.getElementById("displaySenderOpinoinDiv");
		if(spanObj!=null){spanObj.innerHTML="";}
	}
	//意见录入框:320
	
//	spanObj=opinionSpans.get("my:"+position);
//	if(spanObj != null){
//		spanObj.innerHTML += opinionInputWindow(parent.tempOpinion,parent.canUploadRel,relAttButton,
//				parent.canUploadAttachment,attButton,attContfileUpload,parent.attitudeString,parent.commonPhrase);
//		spanObj.style.height="100%";
//		spanObj.focus();
//	}                      
}catch(e){}
}

function hiddeBorder(opn)
{		
	var ops = opn.split(",");
	var spanObj;
	if(opinionSpans==null){initSpans();}
	for(i=0;i<ops.length;i++)
	{
		spanObj=opinionSpans.get("my:"+ops[i]);
		if(spanObj!=null)
		{			
			spanObj.style.border="0px";			
		}
	}
	//20090917guoss修改，其它意见不在ops中，将其它意见的文本框也同时去掉
	if(opinionSpans.get("my:otherOpinion") !=null){
			opinionSpans.get("my:otherOpinion").style.border="0px";
		}
}


/*新建公文，公文提交的时候需要把disable的数据变成可编辑的，否则不能提交到后台
 * 如果已经是修改状态，不做任何修改，如果为disable状态，需要根据数值转换成selet
 * 
 */
 
 function adjustReadFormForSubmit(){
 	
 	try{
 		//公文单下拉不能disable
  		var selEdoctable=document.getElementById("edoctable");
  		if(selEdoctable!=null)
  		{
  			selEdoctable.disabled=false;
  		}
 	}catch(e)
 	{ 		
 	}
	
	var s = document.getElementById("xml").value;
	var x = document.getElementById("xslt").value;
	
	var str = s;
	var xslStart = str.indexOf("&&&&&&&  xsl_start  &&&&&&&&");
	var dataStart = str.indexOf("&&&&&&&&  data_start  &&&&&&&&");
	var inputStart = str.indexOf("&&&&&&&&  input_start  &&&&&&&&");
	
	if(xslStart == -1)
			throw  "没有找到xsl";
	if(dataStart == -1)
			throw "没有找到data";
	if(inputStart == -1)
			throw "没有找到input";
	var xsl = str.slice(xslStart + 28, dataStart);
	var data = str.slice(dataStart + 30, inputStart);
	var finput = str.slice(inputStart + 31);	
  	ajustReadInput(finput);  	
}

function ajustReadInput(aInput)
{
	var fFiledList = paseFormatXML(getXmlContent(aInput));	
	adjustConvertReadHtml(fFiledList);
	var repeatTable = new Seeyonform_rtable();
	repeatTable.change();
	
	var reSection = new Seeyonform_rsection();
	reSection.change();
}
function changeSelectValue(dis,SeeyonformSelect)
{
	var i;
	var ls=	SeeyonformSelect.valueList;
	for(i=0;i<ls.length;i++)
	{
		if(ls[i].label==dis)
		{
			return ls[i].value;
		}
	}
	return dis;
}
function adjustConvertReadHtml(aFieldList){
	var field;
	var fAreas;
	var ocxNameList="";
	for(var i = 0; i < aFieldList.length; i++){
		 field = aFieldList[i];
		 var inputObj=document.getElementById(field.fieldName);
		 if(inputObj==null){continue;}
		 var isSel= field instanceof Seeyonform_select;
		 
		 if(inputObj.disabled==false&&inputObj.readOnly==false){continue;}
		 
		 if(ocxNameList.indexOf("["+field.fieldName+"]")==-1){ocxNameList+="["+field.fieldName+"]";}
		 else {if(isSel==false){continue;}}
		 
		 if(isSel)
		 {
		 	inputObj.value=changeSelectValue(inputObj.value,field);
		 }		 
		 inputObj.disabled=false;
		 inputObj.canSubmit="true";			 
  }
}

/***************公文单控制部分结束*******************/

//----------------------------  公文套红部分中

//套红的时候，如果是联合发文，会用两个单位的套红模板将正文分别套红，形成两套正文。
//套红的时候，如果是联合发文，检查公文的第一套正文或者第二套正文是否已经被创建，没有创建就创建，已经创建就返回当前正文ID
//创建的方式：createContentBody会在后台向edocbody表中添加记录，并且返回新的正文ID（newOfficeID）,
//          并且将newOfficeID赋值给控件的fileID.,这样保存的时候就会创建新的正文，并且向file表中添加新的记录。
function checkExistBody()
{
	var isUniteSend=document.getElementById("isUniteSend").value;
	var summaryId=theform.summary_id.value;
	var contentNum=theform.currContentNum.value;
	var bodyType = document.getElementById("bodyType").value;	
	if(contentUpdate==false || isUniteSend!="true"){return ;}
	if(contentOfficeId.get(contentNum,null)==null)
  	{
  		var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "createContentBody",false);
		requestCaller.addParameter(1, "String", summaryId);
		requestCaller.addParameter(2, "int", contentNum);
		requestCaller.addParameter(3, "String", contentOfficeId.get("0",null));
		requestCaller.addParameter(4, "String", bodyType);
		var ds = requestCaller.serviceRequest();
		fileId=ds;		
		contentOfficeId.put(contentNum,ds);		
  	}
  	else
  	{
  		fileId=contentOfficeId.get(contentNum,null);
  	}
  	return fileId;
  	//setOfficeOcxRecordID(fileId);
}

//新建公文模板的时候进行正文套红
function taohongWhenTemplate(templateType){
	var bodyType = document.getElementById("bodyType").value;
	var loginAccountId=document.getElementById("loginAccountId").value;
   	if(bodyType=="HTML" && templateType=="edoc")
   	{
  	 	alert(_("edocLang.edoc_htmlnofuntion"));
  	 	return;
   	}
  	if(bodyType=="OfficeExcel" && templateType=="edoc")//excel不能进行正文套红。
   	{
  	 	alert(_("edocLang.edoc_excelnofuntion"));
  	 	return;
   	}
  	if( bodyType == "WpsExcel" && templateType=="edoc")//et不能进行正文套红。
   	{
  	 	alert(_("edocLang.edoc_wpsetnofuntion"));
  	 	return;
   	}
	if(bodyType=="Pdf" && templateType=="edoc"){
	    alert(_("edocLang.edoc_pdfnofuntion"));
	    return;
	}
		//Ajax判断是否存在套红模板
	if(!hasEdocDocTemplate(loginAccountId,templateType,bodyType)){
		alert(v3x.getMessage('edocLang.edoc_docTemplate_record_notFound'));
		return;
	}
	//判断是否是联合发文
	var docMark=document.getElementById("my:doc_mark");
	var docMark2=document.getElementById("my:doc_mark2");
	var isUniteSend=docMark&&docMark2?"true":"false";
	//document.getElementById("isUniteSend").value=isUniteSend;
	var contentNumObj=document.getElementById("currContentNum");
	if(isUniteSend=="true"){
		alert(_("edocLang.edoc_UniteSendnofuntion"));
		return;
	}
	
	if(bodyType.toLowerCase()=="officeword" || bodyType.toLowerCase()=="wpsword" || templateType=="script"){
  	   if(templateType=="edoc")
  	   {
  	   	//正文套紅將會自動清稿，你確定要這麼做嗎?
  	     if(confirm(_("edocLang.edoc_alertAutoRevisions"))){
  	     	//清除正文痕迹并且保存
  	     	//removeTrailAndSave();
  	     	//清除正文痕迹并且保存,与处理过程中的框架结构不一样，所以采用另外的方法
  	     	if(!removeTrailAndSaveWhenTemplate()){
  	     		alert(_("edocLang.edoc_contentSaveFalse")); 
  	     		return;
  	     	}		
  	     }else {
  	     	 return;
  	     }
  	   }
  	   //设置原始正文的ID
  	   //保存的时候后台生成的ID才是正文真正的ID，JSP页面生成的ID不起作用。
  	   if(templateType=="script"){bodyType="";}
   	   var receivedObj = v3x.openWindow({
     	   url: templateURL + "?method=taoHongEntry&templateType="+templateType+"&bodyType="+bodyType+"&isUniteSend="+isUniteSend+"&orgAccountId="+loginAccountId,
     	   width:"350",
    	   height:"250"
  	  });
	  if(receivedObj==null){return;}
  	  var taohongTemplateContentType="";
  	  if(isUniteSend=="true" && templateType=="edoc"){
  	  	 var ts=receivedObj[0].split("&");
  	  	 taohongTemplateContentType=ts[1];
  	  	 receivedObj[0]=ts[0];
  	  }
  	  else
  	  {
  	  	 var ts=receivedObj.split("&");
  	  	 taohongTemplateContentType=ts[1];
  	  	 receivedObj=ts[0];
  	  }
  	  if(taohongTemplateContentType=="officeword"){taohongTemplateContentType="OfficeWord";}
  	  else if(taohongTemplateContentType=="wpsword"){taohongTemplateContentType="WpsWord";}  	  
  	  
  	  if(receivedObj==null){return;}
  	  if(templateType=="script")
  	  {
  	  	var urlStr=genericURL + "?method=wendanTaohongIframe&summaryId="+document.getElementById("summaryId").value;
  	  	urlStr+="&tempContentType="+taohongTemplateContentType;
  	  	
  	  	page_receivedObj=receivedObj;
  	  	page_templateType=templateType;
  	  	page_extendArray=extendArray;
  	  	
  	  	v3x.openWindow({url: urlStr,workSpace: 'yes'});
  	  	var redForm = parent.parent.detailRightFrame.theform.redForm;
  	  	if(redForm && templateType=="script"){
  	  			redForm.value = "true";
  	  		}
  	    //window.open(urlStr);
  	  }
  	  else
  	  {  	  	
  	  	setOfficeOcxRecordID(fileId);
  	  	if(isUniteSend!="true")
  	  	{
  	  		officetaohong(document.getElementsByName("sendForm")[0],receivedObj,templateType,extendArray);
  	  		contentUpdate=true;
  	  		hasTaohong = true ;
  	  	}
  	  	else
  	  	{  	  		
  	  		officetaohong(document.getElementsByName("sendForm")[0],receivedObj[0],templateType,extendArray);
  	  		contentNumObj.value=receivedObj[1];
  	  		//设置此参数，用于保存公文和发送公文时候保存正文。
  	  		document.getElementById("contentNo").value=receivedObj[1];
  	  		contentUpdate=true;
  	  		hasTaohong = true ;
  	  	}
  	  }
  	}
}


//拟文的时候进行正文套红，与处理过程中的套红有所区别所以拟文的时候进行正文套红单独使用此方法
//function taohongWhenDraft(templateType)
//{
//
//	var bodyType = document.getElementById("bodyType").value;	
//	//Ajax判断是否存在套红模板
//	if(!hasEdocDocTemplate(templateType,bodyType)){
//		alert(v3x.getMessage('edocLang.edoc_docTemplate_record_notFound'));
//		return;
//	}
//	//var isUniteSend=document.getElementById("isUniteSend").value;
//	//判断是否是联合发文
//	
//	var docMark=document.getElementById("my:doc_mark");
//	var docMark2=document.getElementById("my:doc_mark2");
//	var isUniteSend=docMark&&docMark2?"true":"false";
//	document.getElementById("isUniteSend").value=isUniteSend;
//	var contentNumObj=document.getElementById("currContentNum");
//	
//   if(bodyType=="HTML" && templateType=="edoc")
//   {
//  	 alert(_("edocLang.edoc_htmlnofuntion"));
//  	 return;
//   }
//   if(bodyType=="OfficeExcel" && templateType=="edoc")//excel不能进行正文套红。
//   {
//  	 alert(_("edocLang.edoc_excelnofuntion"));
//  	 return;
//   }
//   else if(bodyType.toLowerCase()=="officeword" || bodyType.toLowerCase()=="wpsword" || templateType=="script"){
//  	   if(templateType=="edoc")
//  	   {
//  	   	//正文套紅將會自動清稿，你確定要這麼做嗎?
//  	     if(confirm(_("edocLang.edoc_alertAutoRevisions"))){
//  	     	//清除正文痕迹并且保存
//  	     	//removeTrailAndSave();
//  	     	//清除正文痕迹并且保存,与处理过程中的框架结构不一样，所以采用另外的方法
//  	     	if(!removeTrailAndSaveWhenDraft()){
//  	     		alert(_("edocLang.edoc_contentSaveFalse")); 
//  	     		return;
//  	     	}		
//  	     }else {
//  	     	 return;
//  	     }
//  	   }
//  	   //设置原始正文的ID
//  	   //保存的时候后台生成的ID才是正文真正的ID，JSP页面生成的ID不起作用。
//		if(oFileId==""){
//			oFileId=fileId;
//		}
//  	   if(templateType=="script"){bodyType="";}
//   	   var receivedObj = v3x.openWindow({
//     	   url: templateURL + "?method=taoHongEntry&templateType="+templateType+"&bodyType="+bodyType+"&isUniteSend="+isUniteSend,
//     	   width:"350",
//    	   height:"250"
//  	  });
//	  if(receivedObj==null){return;}
//  	  var taohongTemplateContentType="";
//  	  if(isUniteSend=="true" && templateType=="edoc"){
//  	  	 var ts=receivedObj[0].split("&");
//  	  	 taohongTemplateContentType=ts[1];
//  	  	 receivedObj[0]=ts[0];
//  	  }
//  	  else
//  	  {
//  	  	 var ts=receivedObj.split("&");
//  	  	 taohongTemplateContentType=ts[1];
//  	  	 receivedObj=ts[0];
//  	  }
//  	  if(taohongTemplateContentType=="officeword"){taohongTemplateContentType="OfficeWord";}
//  	  else if(taohongTemplateContentType=="wpsword"){taohongTemplateContentType="WpsWord";}  	  
//  	  
//  	  if(receivedObj==null){return;}else{
//  	  	//设置隐藏域的值，用来记录日志，是否进行了套红。
////  	  	var redContent = parent.parent.detailRightFrame.theform.redContent;
////  	  	if(redContent && templateType=="edoc"){
////  	  			redContent.value = "true";
////  	  		}
//  	  	}
//  	  if(templateType=="script")
//  	  {
//  	  	var urlStr=genericURL + "?method=wendanTaohongIframe&summaryId="+document.getElementById("summaryId").value;
//  	  	urlStr+="&tempContentType="+taohongTemplateContentType;
//  	  	
//  	  	page_receivedObj=receivedObj;
//  	  	page_templateType=templateType;
//  	  	page_extendArray=extendArray;
//  	  	
//  	  	v3x.openWindow({url: urlStr,workSpace: 'yes'});
//  	  	var redForm = parent.parent.detailRightFrame.theform.redForm;
//  	  	if(redForm && templateType=="script"){
//  	  			redForm.value = "true";
//  	  		}
//  	    //window.open(urlStr);
//  	  }
//  	  else
//  	  {  	  	
//  	  	setOfficeOcxRecordID(oFileId);
//  	  	if(isUniteSend!="true")
//  	  	{
//  	  		officetaohong(document.getElementsByName("sendForm")[0],receivedObj,templateType,extendArray);
//  	  		contentUpdate=true;
//  	  		hasTaohong = true ;
//  	  	}
//  	  	else
//  	  	{  	  		
//  	  		officetaohong(document.getElementsByName("sendForm")[0],receivedObj[0],templateType,extendArray);
//  	  		contentNumObj.value=receivedObj[1];
//  	  		//设置此参数，用于保存公文和发送公文时候保存正文。
//  	  		document.getElementById("contentNo").value=receivedObj[1];
//  	  		contentUpdate=true;
//  	  		hasTaohong = true ;
//  	  	}
//  	  }
//  	}
//  }
 //ajax判断是否存在套红模板
function hasEdocDocTemplate(orgAccountId,templateType,bodyType){
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocDocTemplateController", "hasEdocDocTemplate",false);
	requestCaller.addParameter(1, "Long", orgAccountId); 
  	requestCaller.addParameter(2, "String", templateType);  
  	requestCaller.addParameter(3, "String", bodyType);  	
  	var ds = requestCaller.serviceRequest();  
  	//"0":没有，“1”：有	
  	if(ds=="1"){return true;}
  	else {return false;} 
}
//ajax判断是否签章
function checkIsHaveHtmlSign(summaryId){
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "isHaveHtmlSign",false);
	requestCaller.addParameter(1, "String", summaryId);
  	var ds = requestCaller.serviceRequest();
  	return ds;
}
//处理过程中的正文套红
function taohong(templateType)
{
	var bodyType = document.getElementById("bodyType").value;	
	var isUniteSend=document.getElementById("isUniteSend").value;
	var contentNumObj=document.getElementById("currContentNum");
	var orgAccountId=document.getElementById("orgAccountId").value;
	
   	if(bodyType=="HTML" && templateType=="edoc")
   	{
  	 	alert(_("edocLang.edoc_htmlnofuntion"));
  	 	return;
   	}
   	if(bodyType=="OfficeExcel" && templateType=="edoc")//excel不能进行正文套红。
   	{
  	 	alert(_("edocLang.edoc_excelnofuntion"));
  	 	return;
   	}
 	if(bodyType == "WpsExcel" && templateType=="edoc")//excel不能进行正文套红。
   	{
  	 	alert(_("edocLang.edoc_wpsetnofuntion"));
  	 	return;
   	}
	if(bodyType=="Pdf" && templateType=="edoc"){
	    alert(_("edocLang.edoc_pdfnofuntion"));
	    return;
	}
	//判断文号是否为空
	if(templateType=="edoc") {
		if(contentIframe.checkEdocWordNoIsNull()==false) {
	        return;
	    }
	}
	//Ajax判断是否存在套红模板
	if(templateType=="script"){bodyType="";}
	if(!hasEdocDocTemplate(orgAccountId,templateType,bodyType)){
		alert(v3x.getMessage('edocLang.edoc_docTemplate_record_notFound'));
		return;
	}
	
	if(bodyType.toLowerCase()=="officeword" || bodyType.toLowerCase()=="wpsword" || templateType=="script"){
  	   if(templateType=="edoc")
  	   {
  	   	//判断是否有印章，有印章的时候不允许套红。
  	   	if(getSignatureCount()>0){
  	   		alert(_("edocLang.edoc_notaohong_signature"));
  			return;
  	   	}
  	   	//正文套紅將會自動清稿，你確定要這麼做嗎?
  	     if(confirm(_("edocLang.edoc_alertAutoRevisions"))){
  	     	//清除正文痕迹并且保存
  	     	if(!removeTrailAndSave())return;	
  	     }else {
  	     	 return;
  	     }
  	   }
   	   var receivedObj = v3x.openWindow({
     	   url: templateURL + "?method=taoHongEntry&templateType="+templateType+"&bodyType="+bodyType+"&isUniteSend="+isUniteSend+"&orgAccountId="+orgAccountId,
     	   width:"350",
    	   height:"250"
  	  });
   
	  if(receivedObj==null){return;}
  	  var taohongTemplateContentType="";
  	  if(isUniteSend=="true" && templateType=="edoc"){
  	  	 var ts=receivedObj[0].split("&");
  	  	 taohongTemplateContentType=ts[1];
  	  	 receivedObj[0]=ts[0];
		taohongSendUnitType = ts[2];
  	  }
  	  else
  	  {
  	  	 var ts=receivedObj.split("&");
  	  	 taohongTemplateContentType=ts[1];
  	  	 receivedObj=ts[0];
		taohongSendUnitType = ts[2];
  	  }
  	  var sendUnitTypeInput = document.createElement("input");
  	  sendUnitTypeInput.id = "taohongSendUnitType";
  	  sendUnitTypeInput.name = "taohongSendUnitType";
  	  sendUnitTypeInput.type = "hidden";
  	  sendUnitTypeInput.value = taohongSendUnitType;
  	  
  	  //GOV-3253 【公文管理】-【发文管理】-【待办】，处理待办公文时进行'文单套红'出现脚本错误
  	  //IE7不支持这句，而且在文单套红时也把选择单位或部门的去掉了，所以这里不用了
  	  //contentIframe.document.getElementsByName("sendForm")[0].appendChild(sendUnitTypeInput);

  	  if(taohongTemplateContentType=="officeword"){taohongTemplateContentType="OfficeWord";}
  	  else if(taohongTemplateContentType=="wpsword"){taohongTemplateContentType="WpsWord";}  	  
  	  
  	  //记录字段值为TRUE，JS用来记录套红操作
  	  if(receivedObj==null){
  		  return;
  	   }else{
  	  	var redContent =document.getElementById("redContent");
  	  	if(redContent && templateType=="edoc"){
  	  			redContent.value = "true";
  	  	}
  	  }
  	  
  	  
  	  if(templateType=="script")
  	  {
  	  	var urlStr=genericURL + "?method=wendanTaohongIframe&summaryId="+document.getElementById("summary_id").value;
  	  	urlStr+="&tempContentType="+taohongTemplateContentType;
  	  	
  	  	page_receivedObj=receivedObj;
  	  	page_templateType=templateType;
  	  	page_extendArray=extendArray;
  	  	
  	  	v3x.openWindow({url: urlStr,workSpace: 'yes'});
  	  	var redForm =document.getElementById("redForm");
  	  	if(redForm && templateType=="script"){
  	  		redForm.value = "true";
  	  	}
  	  }
  	  else
  	  {  	  	
  	  	setOfficeOcxRecordID(contentOfficeId.get("0",null));
  	  	if(isUniteSend!="true")
  	  	{
  	  		officetaohong(contentIframe.document.getElementsByName("sendForm")[0],receivedObj,templateType,extendArray);
  	  		contentUpdate=true;
  	  		hasTaohong = true ;
  	  	}
  	  	else
  	  	{  	  		
  	  		officetaohong(contentIframe.document.getElementsByName("sendForm")[0],receivedObj[0],templateType,extendArray);
  	  		contentNumObj.value=receivedObj[1];
  	  		contentUpdate=true;
  	  		hasTaohong = true ;
  	  	}
  	  }
  	}
  }

function getSendUnitName(unitname) {
	
	if(unitname=="send_unit" || unitname=="send_unit2") {
		var sendUnitId = "";
		var sendUnit = contentIframe.document.getElementById("my:"+unitname);
		if(unitname=="send_unit") {
			sendUnitId = contentIframe.document.getElementById("my:send_unit_id");
		} else {
			sendUnitId = contentIframe.document.getElementById("my:send_unit_id2");
		}
		if(sendUnit.value!=null && sendUnit.value!="") {
			var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "getSendUnitFullName", false);
			requestCaller.addParameter(1, "int", 1); 
			requestCaller.addParameter(2, "String", sendUnit.value);
			requestCaller.addParameter(3, "String", sendUnitId.value); 
			requestCaller.addParameter(4, "long", contentIframe.document.getElementsByName("sendForm")[0].orgAccountId.value); 
			var ds = requestCaller.serviceRequest();
			return ds;
		}
	}
	
	return null;
}

  //-----------------------------------------------
  
  function supervise(){
     document.getElementById("supervise_div_date").className = "";
     document.getElementById("supervise_div_people").className = "";
  }
  
function arrayToArray(array){
	var r = [];
	if(array != null){
		for(var i = 0; i < array.length; i++) {
			r[i] = array[i];
		}
	}
	
	return r;
}
  
//function edocUpdateEdocFlash(processId,activityId,operationType,elements,commandType,manualSelectNodeId,peopleArr,summaryId,conditions,nodes){
//	var rs = null;
//	var str = "";
//		
//	var idArr = new Array();
//	var typeArr = new Array();
//	var nameArr = new Array();
//	var accountIdArr = new Array();
//	var accountShortNameArr = new Array();
//	var selecteNodeIdArr = new Array();
//	var _peopleArr = new Array();
//	var conditionArr = new Array();
//	var nodesArr = new Array();
//	
//	if(commandType == "addNode" || commandType == "replaceNode"){
//		if (!elements) {
//			return false;
//		}
//	
//		var personList = elements[0] || [];
//		var flowType = elements[1] || 0;
//		var isShowShortName = elements[2] || "false";
//		var process_desc_by = "people";
//		
//		str = processId + "," + activityId + "," + operationType + "," + flowType + "," + isShowShortName + "," + process_desc_by;
//		
//		for (var i = 0; i < personList.length; i++) {
//			var person = personList[i];
//			idArr.push(person.id);
//			typeArr.push(person.type);
//			nameArr.push(person.name);
//			accountIdArr.push(person.accountId);
//			accountShortNameArr.push(person.accountShortname);
//			selecteNodeIdArr = [];
//			_peopleArr = [];
//		}
//	}else if(commandType == "delNode"){
//		str = processId + "," + activityId + "," + operationType + "," + null + "," + null + "," + null;
//		idArr = [];
//		typeArr = [];
//		nameArr = [];
//		accountIdArr = [];
//		accountShortNameArr = [];
//		if(manualSelectNodeId && peopleArr && manualSelectNodeId.length != 0 && peopleArr.length != 0){
//			selecteNodeIdArr = arrayToArray(manualSelectNodeId);
//			_peopleArr = arrayToArray(peopleArr);
//		}else{
//			selecteNodeIdArr = [];
//			_peopleArr = [];
//		}
//		if(conditions && conditions.length!=0){
//			conditionArr = arrayToArray(conditions);
//			nodesArr = arrayToArray(nodes);
//		}else{
//			conditionArr = [];
//			nodesArr = [];
//		}
//	}
//	try {
//		var requestCaller = new XMLHttpRequestCaller(null, "ajaxEdocSuperviseManager", "changeProcess", false, "POST");
//		requestCaller.addParameter(1, "String", str);
//		requestCaller.addParameter(2, "String[]", idArr);
//		requestCaller.addParameter(3, "String[]", typeArr);
//		requestCaller.addParameter(4, "String[]", nameArr);
//		requestCaller.addParameter(5, "String[]", accountIdArr);
//		requestCaller.addParameter(6, "String[]", accountShortNameArr);
//		requestCaller.addParameter(7, "String[]", selecteNodeIdArr);
//		requestCaller.addParameter(8, "String[]", _peopleArr);
//		requestCaller.addParameter(9, "String", summaryId);
//		requestCaller.addParameter(10, "String[]", conditionArr);
//		requestCaller.addParameter(11, "String[]", nodesArr);
//		rs = requestCaller.serviceRequest();
//	}
//	catch (ex1) {
//		alert("Exception : " + ex1);
//	}
//	
//    return rs;
//}
//function edocUpdateEdocFlash1(flowProp,policyStr,summaryId){
//	var rs = null;
//	try {
//		var requestCaller = new XMLHttpRequestCaller(null, "ajaxEdocSuperviseManager", "changeProcess1", false, "POST");
//		requestCaller.addParameter(1, "String[]", arrayToArray(flowProp));
//		requestCaller.addParameter(2, "String[]", arrayToArray(policyStr));
//		requestCaller.addParameter(3, "String", summaryId);
//		rs = requestCaller.serviceRequest();
//	}
//	catch (ex1) {
//		alert("Exception : " + ex1);
//	}
//	
//    return rs;
//}
  
  
function selectAllValues(allButton, targetName){
	var objcts = document.getElementsByName(targetName);
	if(objcts != null){
		for(var i = 0; i < objcts.length; i++){
			if(!objcts[i].disabled){
				objcts[i].checked = allButton.checked;
			}
		}
	}
}
function _getWordNoValue(inputObj)
{
	var markStr="";	
	var inputValue="";
	if(inputObj.tagName=="INPUT" && inputObj.type=="text")
	{
		inputValue=inputObj.value;
		markStr=inputValue;
	}
	else if(inputObj.tagName=="SELECT")	
	{
		inputValue=inputObj.options[inputObj.selectedIndex].value;
		if(inputValue==""){return "";}
		markStr=inputValue.split("|")[1];
	}else if(inputObj.tagName=="TEXTAREA"){
		inputValue=inputObj.value;
		markStr=inputValue;
	}	
	return markStr.trim();
}
/*校验是否录入了公文文号*/
function checkEdocWordNo()
{	
	var markStr="";
	var inputObj=document.getElementById("my:doc_mark");
	if(inputObj!=null)
	{		
		markStr=_getWordNoValue(inputObj);
		if(markStr=="")
		{
			alert(_("edocLang.doc_mark_alter_not_null"));
			try{inputObj.focus();}catch(e){}
			return false;
		}	
		var markUsed =checkWordNoUser(markStr);
		if(markUsed)
		{
			alert(_("edocLang.doc_mark_alter_used"));
			return false;
		}
	}
	//bug 29522 公文文号封发时判断问题
	//else{//公文单中需要含有公文文号元素且不能为空才可封发。
	//	alert(_("edocLang.doc_mark_alter_include_and_not_null"));
	//	return false;
	//}
	var isUniteSend=document.getElementById("isUniteSend").value;
	if(isUniteSend=="true")
	{
		inputObj=document.getElementById("my:doc_mark2");
		if(inputObj!=null)
		{
			var markStr1=markStr;
			markStr=_getWordNoValue(inputObj);
			if(markStr=="")
			{
				alert(_("edocLang.doc_mark2_alter_not_null"));
				try{inputObj.focus();}catch(e){}
				return false;
			}
			//检查两个文号是否相同
			if(markStr1==markStr)
			{
				alert(_("edocLang.two_doc_mark_no_equ"));
				return false;
			}
			var markUsed =checkWordNoUser(markStr);
			if(markUsed)
			{
				alert(_("edocLang.doc_mark2_alter_used"));
				return false;
			}
		}
	}
	return true;
}
function checkWordNoUser(docMark)
{
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocMarkManager", "isUsed",false);
  	requestCaller.addParameter(1, "String", docMark);  
  	requestCaller.addParameter(2, "String", document.getElementById("summaryId").value);  	
  	var ds = requestCaller.serviceRequest();  	
  	if(ds=="true"){return true;}
  	else {return false;}  	
}


/*判断公文文号是否为空*/
function checkEdocWordNoIsNull()
{	
	var markStr="";
	var inputObj=document.getElementById("my:doc_mark");
	if(inputObj!=null)
	{		
		markStr=_getWordNoValue(inputObj);
		if(markStr=="")
		{
			alert(_("edocLang.doc_mark_alter_not_null"));
			try{inputObj.focus();}catch(e){}
			return false;
		}	
	}
	return true;
}
//处理时候，跟踪，处理后删除校验
var checkMulitSign_hasShowAlert = false;
function checkMulitSign(nowSelected){
	var afterSignObj = document.getElementsByName("afterSign");
	
	if(checkMulitSign_hasShowAlert == false){
		var flag = 0;
		for(var i = 0; i < afterSignObj.length; i++) {
			if(afterSignObj[i].checked){
				flag++;
			}
		}
		
		if(flag > 1){
			alert(_("edocLang.edoc_alertSignAfterOption"));
			checkMulitSign_hasShowAlert = true;
		}
	}
	
	for(var i = 0; i < afterSignObj.length; i++) {
		if(afterSignObj[i].id == nowSelected.id){
			continue;
		}
		
		afterSignObj[i].checked = false;
		if(afterSignObj[i].id=='isTrack'){
			var all = document.getElementById("trackRange_all");
			var part = document.getElementById("trackRange_part");
			if(all!=null) all.checked = false;
			if(part!=null) part.checked = false;
		}
	}
	//当前选择的是处理后归档
	var showPrePigeonhole=document.getElementById("showPrePigeonhole");
    var showSelectPigeonholePath=document.getElementById("showSelectPigeonholePath");
	if(nowSelected.id == 'pipeonhole'){
	    if(hasPrepigeonholePath=="true"){//有预归档目录
	        if(nowSelected.checked){  //选择状态，显示，否则隐藏归档路径区域
	            showPrePigeonhole.style.display="";
	        }else{
	            showPrePigeonhole.style.display="none";
	        }
	    }else if(hasPrepigeonholePath=='false'){//模板中没有设置预先归档
	        if(nowSelected.checked){
	            showSelectPigeonholePath.style.display="";
	        }else{
	            showSelectPigeonholePath.style.display="none";
	        }
	    }
	}else if(nowSelected.id =='track'){
		if(nowSelected.checked){
			if(showPrePigeonhole){
				showPrePigeonhole.style.display="none";
			}
			if(showSelectPigeonholePath){
				showSelectPigeonholePath.style.display="none";
			}
		}
	}
}
function chanageHtmlBodyType(contentType)
{
	var ret=chanageBodyType(contentType);
	if(ret)
	{//清空office的id
		var contentObj=document.getElementById("content");
		if(contentObj!=null)
		{
			contentObj.value="";
		}
	}
}

function substituteLogo(logoURL){
	    	//substitution of logo 【logo的替换】
    		var i,key,style,width,height;	
			var spanObjs=document.getElementsByTagName("span");
			for(i=0;i<spanObjs.length;i++)
			{		
				key=spanObjs[i].getAttribute("xd:binding");
				style = spanObjs[i].getAttribute("style");
				if(style!=null){
					if(typeof (style) == "string"){
						var _f = style.indexOf('width');
						if(_f!=-1){
							var _f2 = style.indexOf(':',_f);
							var _f3 = style.indexOf(';',_f);
							width = style.substring(_f2+1,_f3);
						}
						var _h = style.indexOf('height');
						if(_h!=-1){
							var _h2 = style.indexOf(':',_h);
							var _h3 = style.indexOf(';',_h);
							height = style.substring(_h2+1,_h3);
						}
					}else{
						width = style.getAttribute("width");
						height = style.getAttribute("height");
					}
					if(key == 'my:logoimg'){
						logoURL = logoURL.replace('img', 'img width='+ width + ' height='+ height);
						spanObjs[i].outerHTML = logoURL;
					}
				}
			}		
}

function checkExchangeAccountIsDuplicatedOrNot(){

	var returnValue = true;
	
	var sendToIds = getIdsString(selPerElements.get("my:send_to"),false);
	var reportToIds = getIdsString(selPerElements.get("my:report_to"),false);
	var copyToIds = getIdsString(selPerElements.get("my:copy_to"),false);

	//如果主送，抄报，抄送都存在
	if(sendToIds!=null && sendToIds !="" && reportToIds!=null && reportToIds != "" && copyToIds != null && copyToIds !=""){
	var tempArray_a = sendToIds.split(",");
	var tempArray_b = reportToIds.split(",");	
	var tempArray_c = copyToIds.split(",");
	for(var i=0;i<tempArray_a.length;i++){
		for(var j=0;j<tempArray_b.length;j++){
			if(tempArray_a[i] == tempArray_b[j]){;
				returnValue = false;
				break;
			}
				for(var z=0;z<tempArray_c.length;z++){
					if(tempArray_b[j] == tempArray_c[z] || tempArray_a[i] == tempArray_c[z]){
				returnValue = false;
				break;
					}
				}
		}
	}
	}
	
	//如果有主送，有抄报，而无抄送
	else if((sendToIds!=null && sendToIds !="") && (copyToIds !=null && copyToIds!="") && (reportToIds == null || reportToIds == "")){
	var tempArray_a = sendToIds.split(",");	
	var tempArray_c = copyToIds.split(",");
	for(var i=0;i<tempArray_a.length;i++){
				for(var z=0;z<tempArray_c.length;z++){
					if(tempArray_a[i] == tempArray_c[z]){
				returnValue = false;
				break;					}
				}
		}	
	}
	
	//如果有主送，有抄送，而无抄报
	else if((sendToIds!=null && sendToIds !="") && (reportToIds!=null && reportToIds != "") && (copyToIds ==null || copyToIds=="")){
	var tempArray_a = sendToIds.split(",");
	var tempArray_b = reportToIds.split(",");	
	for(var i=0;i<tempArray_a.length;i++){
				for(var j=0;j<tempArray_b.length;j++){
					if(tempArray_a[i] == tempArray_b[j]){
				returnValue = false;
				break;					}
				}
		}	
	}
	
	//如果无主送，有抄送，有抄报
	else if((reportToIds!=null && reportToIds != null) && (copyToIds !=null && copyToIds!="") && (sendToIds==null || sendToIds =="")){
	var tempArray_b = reportToIds.split(",");	
	var tempArray_c = copyToIds.split(",");	
	for(var i=0;i<tempArray_b.length;i++){
				for(var j=0;j<tempArray_c.length;j++){
					if(tempArray_b[i] == tempArray_c[j]){
						returnValue = false;
						break;
					}
				}
		}	
	}
	
	var sendToIds2 = getIdsString(selPerElements.get("my:send_to2"),false);
	var reportToIds2 = getIdsString(selPerElements.get("my:report_to2"),false);
	var copyToIds2 = getIdsString(selPerElements.get("my:copy_to2"),false);
	
	//如果主送，抄报，抄送都存在
	if(sendToIds2!=null && sendToIds2 !="" && reportToIds2!=null && reportToIds2 != "" && copyToIds2 != null && copyToIds2 !=""){
	var tempArray_a2 = sendToIds2.split(",");
	var tempArray_b2 = reportToIds2.split(",");	
	var tempArray_c2 = copyToIds2.split(",");
	for(var i=0;i<tempArray_a2.length;i++){
		for(var j=0;j<tempArray_b2.length;j++){
			if(tempArray_a2[i] == tempArray_b2[j]){;
				returnValue = false;
				break;
			}
				for(var z=0;z<tempArray_c2.length;z++){
					if(tempArray_b2[j] == tempArray_c2[z] || tempArray_a2[i] == tempArray_c2[z]){
				returnValue = false;
				break;
					}
				}
		}
	}
	}
	
	//如果有主送，有抄报，而无抄送
	else if((sendToIds2!=null && sendToIds2 !="") && (copyToIds2 !=null && copyToIds2!="") && (reportToIds2 == null || reportToIds2 == "")){
	var tempArray_a2 = sendToIds2.split(",");	
	var tempArray_c2 = copyToIds2.split(",");
	for(var i=0;i<tempArray_a2.length;i++){
				for(var z=0;z<tempArray_c2.length;z++){
					if(tempArray_a2[i] == tempArray_c2[z]){
				returnValue = false;
				break;					}
				}
		}	
	}
	
	//如果有主送，有抄送，而无抄报
	else if((sendToIds2!=null && sendToIds2 !="") && (reportToIds2!=null && reportToIds2 != "") && (copyToIds2 ==null || copyToIds2=="")){
	var tempArray_a2 = sendToIds2.split(",");
	var tempArray_b2 = reportToIds2.split(",");	
	for(var i=0;i<tempArray_a2.length;i++){
				for(var j=0;j<tempArray_b2.length;j++){
					if(tempArray_a2[i] == tempArray_b2[j]){
				returnValue = false;
				break;					}
				}
		}	
	}
	
	//如果无主送，有抄送，有抄报
	else if((reportToIds2!=null && reportToIds2 != null) && (copyToIds2 !=null && copyToIds2!="") && (sendToIds2==null || sendToIds2 =="")){
	var tempArray_b2 = reportToIds2.split(",");	
	var tempArray_c2 = copyToIds2.split(",");	
	for(var i=0;i<tempArray_b2.length;i++){
				for(var j=0;j<tempArray_c2.length;j++){
					if(tempArray_b2[i] == tempArray_c2[j]){
						returnValue = false;
						break;
					}
				}
		}	
	}
	
	return returnValue;


}
function selectInsertPeopleOK(){
	//把流程操作后的数据放到隐藏域中
	try { top.endProc(); }catch (e) { }
	
	if(v3x.isFirefox) {
		if(document.getElementById("monitorFrame")!=null) {
			document.getElementById("monitorFrame").src = document.getElementById("monitorFrame").src;
		}
	} else {
		monitorFrame.location.href = monitorFrame.location.href;
	}
	
	//showPrecessArea();
	this.waitMin = function (){
		showPrecessAreaTd("workflow");
	}
	setTimeout(this.waitMin, 1);
}
	function showAttention(object){
		var divObj = document.getElementById(object);
		var divLeft = event.x;
		if(divLeft+220>document.body.clientWidth){
			divLeft = event.x - 220;
		}
  		divObj.style.top =  event.y - 50;
  		divObj.style.left = divLeft - 150;
  		divObj.style.height = 25;
  		divObj.style.width = 250;
  		divObj.style.display = "block";
  	}
  	
  	function hideAttention(object){
  		var divObj = document.getElementById(object);
  		divObj.style.display = "none";
  	}
  	
  		function showNextSpecialCondition(conditionObject) {
		    var options = conditionObject.options;
		
		    for (var i = 0; i < options.length; i++) {
		        var d = document.getElementById(options[i].value + "Div");
		        //alert(d);
		        if (d) {
		            d.style.display = "none";
		        }
		  }
	if(document.getElementById(conditionObject.value + "Div") == null) return;
		    document.getElementById(conditionObject.value + "Div").style.display = "block";
	}
	
	
function quoteDocument() {
	if(v3x.getBrowserFlag('openWindow')){
	    var atts = v3x.openWindow({
	        url: genericURL + "?method=showList4QuoteFrame",
	        workSpace: 'yes'
	    });
	
	    if (atts) {
	        for (var i = 0; i < atts.length; i++) {
	            var att = atts[i]
	            //addAttachment(type, filename, mimeType, createDate, size, fileUrl, canDelete, needClone, description)
	            addAttachment(att.type, att.filename, att.mimeType, att.createDate, att.size, att.fileUrl, true, false, att.description, null, att.mimeType + ".gif", att.reference, att.category)
	        }
	    }
	}else{
		var win = v3x.openDialog({
			id:"pigeonholeIpad",
	    	title:v3x.getMessage("edocLang.contactdoc"),
	    	url : genericURL + "?method=showList4QuoteFrame",
	    	width: 600,
	        height: 600,
	        //isDrag:false,
	        targetWindow:window.parent.detailMainFrame,
	        //fromWindow:window,
	        type:'window',
	        //relativeElement:obj,
	        buttons:[{
				id:'btn1',
	            text: v3x.getMessage("edocLang.ok"),
	            handler: function(){    	        	
	        		var returnValues = win.getReturnValue();
	        		if (returnValues) {
	        	        for (var i = 0; i < returnValues.length; i++) {
	        	            var att = returnValues[i]
	        	            //addAttachment(type, filename, mimeType, createDate, size, fileUrl, canDelete, needClone, description)
	        	            addAttachment(att.type, att.filename, att.mimeType, att.createDate, att.size, att.fileUrl, true, false, att.description, null, att.mimeType + ".gif", att.reference, att.category)
	        	        }
	        	    }
	        		win.close();
            }
	            
	        }, {
				id:'btn2',
	            text: v3x.getMessage("edocLang.cancel"),
	            handler: function(){
	        		win.close();
	            }
	        }]
		});
	}
}

function quoteDocumentUnSelected(url){
	deleteAttachment(url, fileUploadAttachments.containsKey(url));
}

function quoteDocumentSelected(obj, subject, documentType, url){
	if(!obj){
		return;
	}
	if(!obj.checked){
		quoteDocumentUnSelected(url);
		return;
	}
	
	if(!subject || !documentType || !url || fileUploadAttachments.containsKey(url)){
		return;
	}
	
    var type = "2";
    var filename = subject;
    var mimeType = documentType;
    var createDate = "2000-01-01 00:00:00";
    if(obj.getAttribute("createDate")){
		createDate = obj.getAttribute("createDate");
	}
    var fileUrl = url;
    var description = url;

    //Attachment(id, reference, subReference, category, type, filename, mimeType, createDate, size, fileUrl, description, needClone,extension,icon)
    //atts[atts.length] = new Attachment('', '', '', '', type, filename, mimeType, createDate, '0', fileUrl, description);
    //function addAttachment(type, filename, mimeType, createDate, size, fileUrl, canDelete, needClone, description,extension,icon)
    addAttachment(type, filename, mimeType, createDate, '0', fileUrl, true, null, description, documentType, documentType + ".gif");
}

function quoteDocumentOK() {
    var atts = fileUploadAttachments.values().toArray();

    if (!atts || atts.length < 1) {
        alert(getA8Top().v3x.getMessage('collaborationLang.collaboration_alertQuoteItem'));
        return;
    }

    parent.window.returnValue = atts;
    parent.window.close();
}

function officeOcxOperateOver(opType)
{
	if(typeof(openFrom)=="undefined"){return;}
	if(openFrom!="lenPotent"){return;}
	var LogType="";
	if(opType=="print")
	{
		LogType="print";
	}
	else if(opType=="saveLocal")
	{	
		LogType="save";
	}
	
	try{
    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocManager", "writeDocOperateLog", false);
    	requestCaller.addParameter(1, "Long", docId);
    	requestCaller.addParameter(2, "Long", summaryId);
    	requestCaller.addParameter(3, "String", docSubject);
    	requestCaller.addParameter(4, "String", LogType);
    	var ds = requestCaller.serviceRequest();    	
    }catch(e){
    }
}

/**
 * 和协同的保持一致的打开督的页面
 */
function openSuperviseWindow(isFromTemplate){
	
		var mId = document.getElementById("supervisorId");
		var sDate = document.getElementById("awakeDate");
		var sNames = document.getElementById("supervisors");
		var title = document.getElementById("superviseTitle");
		var role = document.getElementById("superviseRole");
		//var canModify = document.getElementById("canModifyAwake");
		var urlStr = colSuperviseURL + "?method=superviseWindow";
		if(mId.value != null && mId.value != ""){
			urlStr += "&supervisorId=" + mId.value + "&supervisors=" + encodeURIComponent(sNames.value) 
			+ "&superviseTitle=" + encodeURIComponent(title.value) + "&awakeDate=" + sDate.value + "&role=" + role.value;
		}
	
        var rv = v3x.openWindow({
	        url: urlStr,
	        height: 300,
	        width: 450
     	});

    	if(rv!=null && rv!="undefined"){
    		var sv = rv.split("|");
    		if(sv.length == 5){
				mId.value = sv[0]; //督办人的ID(添加标识的，为的是向后台传送)
				sDate.value = sv[1]; //督办时间
				sNames.value = sv[2]; //督办人的姓名
				title.value = sv[3];
				role.value = sv[4];
				//canModify.value = sv[4];
			}
    	}
}

/**
 * 打开督办页面（供普通使用）
 */
function openSuperviseWindow(){
	
		var mId = document.getElementById("supervisorId");
		var sDate = document.getElementById("awakeDate");
		var sNames = document.getElementById("supervisors");
		var title = document.getElementById("superviseTitle");
		var summaryId = document.getElementById("id");
		var fromSend = document.getElementById("fromSend");
		if(summaryId){
			summaryId = summaryId.value;
		}
		var urlStr = colSuperviseURL;
		//var canModify = document.getElementById("canModifyAwake");
		if(fromSend.value == "true"){
			    urlStr += "?method=superviseWindowForEdocZCDB";
		}else{
				urlStr += "?method=superviseWindow";
		}
		var unCancelledVisor = document.getElementById("unCancelledVisor");
		var sfTemp = document.getElementById("sVisorsFromTemplate");
		if(mId.value != null && mId.value != ""){
			urlStr += "&supervisorId=" + mId.value + "&supervisors=" + encodeURIComponent(sNames.value) 
			+ "&superviseTitle=" + encodeURIComponent(title.value) + "&awakeDate=" + sDate.value  + "&sVisorsFromTemplate="+sfTemp.value +"&unCancelledVisor="+unCancelledVisor.value;
		}
		urlStr +=  "&summaryId="+summaryId + "&isFromEdoc=yes&currentPage="+currentPage;
        var rv = v3x.openWindow({
	        url: urlStr,
	        height: 300,
	        width: 400
     	});

    	if(rv!=null && rv!="undefined"){
    		var sv = rv.split("|");
    		if(sv.length == 4){
				mId.value = sv[0]; //督办人的ID(添加标识的，为的是向后台传送)
				sDate.value = sv[1]; //督办时间
				sNames.value = sv[2]; //督办人的姓名
				title.value = sv[3];
				//canModify.value = sv[4];
			}
    	}
}

/**
 * 打开督办页面（供模板使用）
 */

function openSuperviseWindowForTemplate(){
	
		var mId = document.getElementById("supervisorId");
		var sDate = document.getElementById("awakeDate");
		var sNames = document.getElementById("supervisors");
		var title = document.getElementById("superviseTitle");
		var role = document.getElementById("superviseRole");
		//var canModify = document.getElementById("canModifyAwake");
		var urlStr = colSuperviseURL + "?method=superviseWindowForTemplate";
		if((mId.value != null && mId.value != "") || (role.value!=null && role.value!= "")){
			urlStr += "&supervisorId=" + mId.value + "&supervisors=" + encodeURIComponent(sNames.value) 
			+ "&superviseTitle=" + encodeURIComponent(title.value) + "&awakeDate=" + sDate.value + "&role=" + role.value;
		}
		urlStr += "&isFromEdoc=yes";		
        var rv = v3x.openWindow({
	        url: urlStr,
	        height: 350,
	        width: 450
     	});

    	if(rv!=null && rv!="undefined"){
    		var sv = rv.split("|");
    		if(sv.length == 6){
				mId.value = sv[0]; //督办人的ID(添加标识的，为的是向后台传送)
				sDate.value = sv[1]; //督办时间
				sNames.value = sv[2]; //督办人的姓名
				title.value = sv[3];
				role.value = sv[4];
				//canModify.value = sv[4];
			}
    	}
}

function showSuperviseWindow(){
	try{
    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocSuperviseManager", "ajaxCheckIsSummaryOver", false);
    	requestCaller.addParameter(1, "Long", summary_id);
    	var ds = requestCaller.serviceRequest();
    	if(ds =="true"){
    		alert(v3x.getMessage('edocLang.edoc_supervise_workflow_over'));
    		return;
	    }
    }catch(e){}
	
	var rv = v3x.openWindow({
    	url: colSuperviseURL + "?method=edocSuperviseWindowEntry&summaryId=" + summary_id,
    	height: 300,
       	width: 400
    });
}

//分枝代码开始
function setCondition(isForm,args,linkId){
    var link = genericControllerURL + "collaboration/templete/compute&isForm=" + isForm;
    if(args!=undefined){
    	link += "&isNew=0&id="+args.id+"&linkId="+linkId+ "&isForce=" + args.isForce;
    }else{
    	link += "&isNew=1";
    }
    var condition = v3x.openWindow({
			url : link,
			width : 440,
			height : 520,
			scrollbars:"no",
			dialogType: "modal",
            resizable: true
	});
	return condition;
}

function selectCondition(){
	var orgId = document.getElementById("orgId").value;
	var orgName = document.getElementById("orgName").value;
	if(orgId==""||orgName==""){
		alert(v3x.getMessage("collaborationLang.branch_selectorg"));
		return;
	}
	var operationSel = document.getElementById("operation");
	var operation = operationSel.options[operationSel.selectedIndex];
	var arr = new Array();
	arr[0] = operation.value;
	arr[1] = operation.value;
	arr[2] = orgId;
	arr[3] = "["+orgName+"]";
	window.returnValue = arr;
	window.close();
}

function ColBranch(){
  this.id=null;
  this.conditionType=null;
  this.formCondition=null;
  this.conditionTitle=null;
  this.conditionDesc=null;
  this.isForce=null;
  this.conditionBase=null;
}

function initCondition(){
	var scripts = document.getElementsByName("scripts");
	if(scripts&&scripts.length>0){
		var prefix = "";
		var parentURL = null;
		/*var isFormFlag = false;
		try{
			isFormFlag = isForm=="true" || isForm==true;
		}catch(e){}
	   	if(isFormFlag){
	   		if(rootNodeName)
		   		prefix = rootNodeName;
		   	else {
		   		parentURL = "parent.detailMainFrame.contentIframe.";
		   		prefix = parent.detailMainFrame.contentIframe.rootNodeName;
		   	}
		   	prefix = prefix.substring(0,prefix.indexOf(":")+1);
	   	}*/
		if(typeof(isNewColl)=="undefined"){
			parentURL = "contentIframe.";
        }
	   	
	   	var reg = new RegExp("[\{][^\{\}]*[\}]","g"); 
	   	var list = new ArrayList();
	   	
	    for(var i=0;i<scripts.length;i++){
	      	var script = scripts[i].value;
	       	var arr = script.match(reg);
	       	if(arr){
		       	for(var j=0;j<arr.length;j++){
		       		script = script.replace(arr[j],(parentURL==null?"":parentURL)+"getFieldValueForFlow(\""+prefix+arr[j].substring(1,arr[j].length-1)+"\")");	
		       	}						        	
	       	}
	       	arr = script.match(/[\[][^\[\]]*[\]]/gi);
	       	if(arr){
	       		for(var j=0;j<arr.length;j++)
	       			if(arr[j].indexOf(":")!=-1)
		       			script = script.replace(arr[j],"\""+arr[j].substring(arr[j].indexOf(":")+1,arr[j].length-1)+"\"");
	       	}
	       	arr = script.match(/include\([^\']*/gi);
	       	if(arr){
	       		//格式：include(team,系统组:'3434328934822');include(secondPost,'4342342345453_-54534534534')
	       		for(var j=0;j<arr.length;j++){
	       			var data = arr[j].substring(arr[j].indexOf(":")+1);
	       			if(data.indexOf("_")!=-1)
	       				data = data.replace(/_/,",");
	       			var con = arr[j].substring(0,arr[j].indexOf(",")+1)+data;
	       			script = script.replace(arr[j],con);
	       		}
	       	}
	       	arr = script.match(/exclude\([^\']*/gi);
	       	if(arr){
	       		//格式：exclude(team,系统组:3434328934822)
	       		for(var j=0;j<arr.length;j++){
	       			var data = arr[j].substring(arr[j].indexOf(":")+1);
	       			if(data.indexOf("_")!=-1)
	       				data = data.replace(/_/,",");
	       			var con = arr[j].substring(0,arr[j].indexOf(",")+1)+data;
	       			script = script.replace(arr[j],con);
	       		}
	       	}
	       	script = script.replace(/<>/g,"!=");
	       	eval(script);
	    }
	}
}


function initCondition_edoc(isNewColl){
	var scripts = document.getElementsByName("scripts");
	if(scripts&&scripts.length>0){
		var prefix = "";
		var parentURL = null;
		/*var isFormFlag = false;
		try{
			isFormFlag = isForm=="true" || isForm==true;
		}catch(e){}
	   	if(isFormFlag){
	   		if(rootNodeName)
		   		prefix = rootNodeName;
		   	else {
		   		parentURL = "parent.detailMainFrame.contentIframe.";
		   		prefix = parent.detailMainFrame.contentIframe.rootNodeName;
		   	}
		   	prefix = prefix.substring(0,prefix.indexOf(":")+1);
	   	}*/
		if(typeof(isNewColl)=="undefined"){
			parentURL = "_parent.contentIframe.";
        }else{
        	parentURL = "_parent.";
        }
	   	var reg = new RegExp("[\{][^\{\}]*[\}]","g"); 
	   	var list = new ArrayList();
	   	//定义存储计算之前的js字符串
	   	var beforeScripts = new Array();
	   	//定义从表单页面获的相应值<value,表达式>
	   	var formDataTrace= new Properties();
	   	//定义存储计算之后的js字符串
	   	var afterStripts = new Array();
	    for(var i=0;i<scripts.length;i++){
	      	var script = scripts[i].value;
	      	if(isDebug){
	      		//记录下运算之前的js运算字符串
	      		beforeScripts[i] = script;
	      	}
	       	var arr = script.match(reg);
	       	if(arr){
		       	for(var j=0;j<arr.length;j++){
		       		var tempFieldName= prefix+arr[j].substring(1,arr[j].length-1);
		       		script = script.replace(arr[j],(parentURL==null?"":parentURL)+"getFieldValueForFlow(\""+tempFieldName+"\")");
		       		formValue = eval((parentURL==null?"":parentURL)+"getFieldValueForFlow(\""+tempFieldName+"\")");
		       		formDataTrace.put(""+formValue,"pageData:[\""+tempFieldName+"\"]");
		       	}						        	
	       	}
	       	arr = script.match(/[\[][^\[\]]*[\]]/gi);
	       	if(arr){
	       		for(var j=0;j<arr.length;j++)
	       			if(arr[j].indexOf(":")!=-1)
		       			script = script.replace(arr[j],"\""+arr[j].substring(arr[j].indexOf(":")+1,arr[j].length-1)+"\"");
	       	}
	       	arr = script.match(/include\([^\']*/gi);
	       	if(arr){
	       		//格式：include(team,系统组:'3434328934822');include(secondPost,'4342342345453_-54534534534')
	       		for(var j=0;j<arr.length;j++){
	       			var data = arr[j].substring(arr[j].indexOf(":")+1);
	       			if(data.indexOf("_")!=-1)
	       				data = data.replace(/_/,",");
	       			var con = arr[j].substring(0,arr[j].indexOf(",")+1)+data;
	       			script = script.replace(arr[j],con);
	       		}
	       	}
	       	arr = script.match(/exclude\([^\']*/gi);
	       	if(arr){
	       		//格式：exclude(team,系统组:3434328934822)
	       		for(var j=0;j<arr.length;j++){
	       			var data = arr[j].substring(arr[j].indexOf(":")+1);
	       			if(data.indexOf("_")!=-1)
	       				data = data.replace(/_/,",");
	       			var con = arr[j].substring(0,arr[j].indexOf(",")+1)+data;
	       			script = script.replace(arr[j],con);
	       		}
	       	}
	       	script = script.replace(/<>/g,"!=");
	       	if(isDebug){
		    	afterStripts[i] = script;
		    }
	       	eval(script);
	    }
	    if(isDebug){
	    	//跟踪代码开始
	    	try{
	    		var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "createBranchLogData", false);
	    		requestCaller.addParameter(1,"String[]",beforeScripts);
		    	requestCaller.addParameter(2,"String[]",afterStripts);
		    	var teamstr="";
		    	for(var i in team){
		    		teamstr +="["+i+"],";
		    	}
		    	var secondpoststr="";
		    	for(var i in secondpost){
		    		secondpoststr +="["+i+"],";
		    	}
		    	var startTeamstr="";
		    	for(var i in startTeam){
		    		startTeamstr +="["+i+"],";
		    	}
		    	var startSecondpoststr="";
		    	for(var i in startSecondpost){
		    		startSecondpoststr +="["+i+"],";
		    	}
		    	requestCaller.addParameter(3,"String",teamstr);
		    	requestCaller.addParameter(4,"String",secondpoststr);
		    	requestCaller.addParameter(5,"String",startTeamstr);
		    	requestCaller.addParameter(6,"String",startSecondpoststr);
		    	requestCaller.addParameter(7,"String",formDataTrace.toString());
		    	requestCaller.addParameter(8,"String","edoc");
		    	requestCaller.serviceRequest();
	    	}catch(e){
	    		alert(e);
	    	}
    		//跟踪代码结束
	    }
	}
}

function moreCondition(moreInfo,readonly){
	var readOnly = readonly?readonly:false;
	var link = genericControllerURL + "collaboration/templete/moreCondition&moreInfo="+encodeURIComponent(moreInfo)+"&readonly="+readOnly;
    
	//var link = genericControllerURL + "collaboration/templete/moreCondition&moreInfo="+encodeURIComponent(moreInfo);
    var moreCondition = v3x.openWindow({
			url : link,
			width : 230,
			height : 195,
			scrollbars:"no"
	});
	return moreCondition;
}

function hiddenFailedCondition(nodeId){	
	var showDiv = document.getElementById("d"+nodeId);
	var hiddenDiv = document.getElementById('failedCondition');
	if(showDiv && hiddenDiv){
		hiddenDiv.innerHTML += showDiv.outerHTML;
		showDiv.outerHTML = "";
	}
	hiddenDiv = document.getElementById('failedConditionSelector');
	if(hiddenDiv){
		showDiv = document.getElementById("selector"+nodeId);
		if(showDiv){
			hiddenDiv.innerHTML += showDiv.outerHTML;
			showDiv.outerHTML = "";
		}
	}
	var showDiv = document.getElementById("aDiv");
	if(showDiv && showDiv.style.display=="none")
		showDiv.style.display = "";
}

function showFailedCondition(labelObj){
	var failedConditionDiv = document.getElementById("failedCondition");
	var failedSelectorDiv = document.getElementById("failedConditionSelector");
	if(failedConditionDiv.style.display=="none"){
		if(failedConditionDiv)
			failedConditionDiv.style.display = "";
		if(failedSelectorDiv)
			failedSelectorDiv.style.display = "";
		labelObj.innerHTML = "["+hideLabel+"]";
	}
	else{
		if(failedConditionDiv)
			failedConditionDiv.style.display = "none";
		if(failedSelectorDiv)
			failedSelectorDiv.style.display = "none";
		labelObj.innerHTML = "["+showLabel+"]";
	}
}
function getFieldValueForFlow(fieldName)
{
	if(self.location.href.search("method=showDiagram")!=-1)
	{
		return parent.detailMainFrame.contentIframe.getFieldValueForFlow(fieldName);
	}
	var objValue="";
	var inputObj=document.getElementById("my:"+fieldName);
	if(inputObj!=null)
	{		
		objValue=_getObjValue(inputObj);		
	}	
	return objValue;	
}

function _getObjValue(inputObj)
{	
	var inputValue="";
	if(inputObj.tagName=="INPUT" && inputObj.type=="text")
	{
		if(inputObj.getAttribute("realValue"))
			inputValue = inputObj.getAttribute("realValue");
		else
			inputValue=inputObj.value;		
	}
	else if(inputObj.tagName=="SELECT")	
	{
		inputValue=inputObj.options[inputObj.selectedIndex].value;		
	}	
	return inputValue;
}

function include(arr,id){
	if(!arr)
		return false;
	for(var i in arr){
		if(i == id)
			return true;
	}
	return false;
}

function exclude(arr,id){
	return !include(arr,id);
}

/**
 *发起/处理时显示分支描述
*/
function showBranchDesc(linkId,templateId){
	if(!templateId){
		var parentWin = window.dialogArguments;
		var desc = "";
		if(parentWin && parentWin.branchs){
			var branch = parentWin.branchs[linkId];
			if(branch)
				desc = branch.conditionDesc;
		}
		moreCondition(desc,true);
	}else{
		//待发时不能从页面取描述信息，只能到数据库中取
		var rv = v3x.openWindow({
	        url: templeteURL + "?method=showBranchDesc&readonly=true&linkId=" + linkId + "&templateId=" + templateId,
	        width : 230,
			height : 195,
			scrollbars:"no"
    	});
	}
}
//分枝代码结束

/**
 * 预发布公告,新闻
 * return 0--失败,1--成功
 */
function TransmitBulletin(policyName, summaryId){
    var bodyType = document.getElementById("bodyType").value;
	if(ocxContentIsModify()==true)
	{//正文为修改状态，是否进行保存
		if(window.confirm(_("edocLang.content_modify_info")))
		{
			if(!saveContent()){return;}
		}
		
	}
	//Ajax判断是否有发布新闻、公告的权限
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocController", "AjaxjudgeHasPermitIssueNewsOrBull", false);
	requestCaller.addParameter(1, "String", policyName);
	var rs = requestCaller.serviceRequest();
	if(rs == "false"){
		alert(_("edocLang.edoc_alertNoPermitBull"));//您沒有發布權限!
		return ;
	}
	var d=new Date();

	var rv = v3x.openWindow({
        url: genericURL + "?method=preIssueNewsOrBull&bodyType=" + bodyType + "&policyName=" + policyName+"&t="+d.getTime(),
        height: 320,
        width: 270
    });
    if(!rv || rv.length == 0) return;
    
    var data = {
        typeId : [],
        summaryId : [],
        memberIdsStr : [],
        allowPrint : [],
        ext5 : []
    };
    
    data.typeId = rv[0];
    data.memberIdsStr = rv[1];
    data.summaryId = summaryId;
    data.allowPrint = rv[2];

	var actionUrl = genericURL+"?method=issusBulletion";
	if(policyName == "newsaudit"){
		actionUrl = collaborationCanstant.issusNewsActionURL;
	}
	if(rv[3] == "1"){
		var fileId = getUUID();
		data.ext5 = fileId;
		transformWordToPdf(fileId);
	}
    submitMap(data, actionUrl, "showDiagramFrame", "post");
    return;
}
function SendBulltinResult(errMsg)
{
	if(errMsg=="")
	{
		alert(_("edocLang.TransmitBulletin_Success"));
	}
	else
	{
		alert(errMsg);
	}
}
//检查正文是否被修改
function ocxContentIsModify()
{
	var bodyType = document.getElementById("bodyType").value;
  	if(bodyType=="HTML" || bodyType == 'Pdf')
  	{
  		return contentUpdate;  		
  	}
  	else
  	{
  		return contentIsModify();
  	}
}
//多级会签
function addMoreSign(_summary_id, _processId, _affairId) {	
	if(!checkModifyingProcessAndLock(processId, summary_id)){
		return;
	}
    selectPeopleFun_addMoreSign();
}
//多级会签div实现
var addMoreSignResult_win;
function addMoreSignResult(elements) {
	if(v3x.getBrowserFlag('pageBreak')){
		var rv = v3x.openWindow({
	        url: genericURL + "?method=preAddMoreSign&selObj="+getIdsString(elements)+"&appName="+appTypeName+"&summary_id="+summaryId,
	        height: 350,
	        width: 500
	    });
	}else{
		if(addMoreSign_win){addMoreSign_win.close();}
		addMoreSignResult_win = v3x.openDialog({
			id:"addMoreSignResult",
			title:v3x.getMessage("edocLang.morepeople"),
	        url: genericURL + "?method=preAddMoreSign&selObj="+getIdsString(elements)+"&appName="+appTypeName+"&summary_id="+summaryId,
	        height: 350,
	        width: 500
	    });
	}
}

function disabledPrecessButtonEdoc(state){
	state = state == null ? true : state;
    try{ document.getElementById("processButton").disabled = state; } catch(e) { }
    try{ document.getElementById("zcdbButton").disabled = state; } catch(e) { }
    //try{ document.getElementById("savedraftButton").disabled = state; } catch(e) { }
}
function unescapeHTMLToString(str){
	if(!str){
		return "";
	}
	
	str = str.replace("&amp;","&");
	str = str.replace("&lt;","<");
	str = str.replace("&gt;",">");
	str = str.replace("<br>","");
	str = str.replace("&#039;","\'");
	str = str.replace("&#034;","\"");
	
	return str;
}
function showProcessLog(processId){
	var url = processLogURL+"?method=processLogIframe&processId="+processId;
	var rv = getA8Top().v3x.openWindow({
	    url: url,
	    dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
	    width: "800",
	    height: "600"
	});
}

function checkMarkHistoryExist(edocMarkHistory,edocId){
	try {
		var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocMarkHistoryManager", "isUsed", false);
		requestCaller.addParameter(1, "String", edocMarkHistory);
		requestCaller.addParameter(2, "Long", edocId);
		var rs = requestCaller.serviceRequest();
		if(rs == "true"){
			alert(_("edocLang.doc_mark_alter_used"));
			return true;
		}
	}
	catch (ex1) {
		alert("Exception : " + ex1);
		return true;
	}	
	return false;
}
//跟踪设置窗口。
/*function preChangeTrack(affairId, isTrack){
	alert("dsds");
	var trackValue = '0';
	if(isTrack){
		trackValue = '1';
	}
    var rv = v3x.openWindow({
        url: genericControllerURL + "collaboration/preChangeTrack&affairId="+affairId+"&trackValue="+trackValue,
        width: "250",
        height: "150"
    });
}*/
function preChangeTrack(affairId, isTrack){
	var trackValue = '0';
	if(isTrack){
		trackValue = '1';
	}
    var rv = v3x.openWindow({
      //  url: genericControllerURL + "collaboration/preChangeTrack&affairId="+affairId+"&trackValue="+trackValue,
        url : colWorkFlowURL+"?method=preChangeTrack&affairId="+affairId+"&trackValue="+trackValue,
    	width: "250",
        height: "150"
    });
    
}
//检查某人是否是某公文的督办人。。
//0 :被取消了督办权限 。1：仍然是督办人。
function isStillSupervisor(summaryId){
	try {
		var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocSuperviseManager", "isSupervisorOfOneSummary", false);
		requestCaller.addParameter(1, "String", summaryId);
		var rs = requestCaller.serviceRequest();
		if(rs == "0"){
			alert(_("edocLang.edoc_alert_not_supervise"));
			return false;
		}
	}
	catch (ex1) {
		alert("Exception : " + ex1);
		return false;
	}	
	return true;
}
/**
 * 检查正文是否存在并发修改。
 */
function checkConcurrentModifyForHtmlContent(contentId){
	  var requestCaller = new XMLHttpRequestCaller(this, "ajaxHandWriteManager", "editObjectState",false);
	  requestCaller.addParameter(1, "String", contentId);  
	  var ds = requestCaller.serviceRequest();
	  if(ds.get("curEditState")=="true")
	  {
	  	//:(getOfficeLanguage("用户")+ds.get("userName")+getOfficeLanguage("正在编辑此文件，不能修改！"));    
	  	alert(v3x.getMessage("V3XOfficeLang.alert_NotEdit",ds.get("userName")));    
	    return true;
	  }
	  return false;
}
/**
 * 解锁HTML正文
 */
function unlockHtmlContent(summaryId){
      var requestCaller = new XMLHttpRequestCaller(this, "ajaxHandWriteManager", "deleteUpdateObj",false);
	  requestCaller.addParameter(1, "String", summaryId);  
	  var ds = requestCaller.serviceRequest();
}

function checkEdocMark(){
	var edocMarkObj = document.getElementById("my:doc_mark");
    if(edocMarkObj){
        if(!isEdocMarkWellFormated(edocMarkObj.value)) return false;
	    var edocMark = _getWordNoValue(edocMarkObj);
	    if(edocMark && edocMark.length>66){
	    	alert(v3x.getMessage("edocLang.mark_alter_exceed"));
	    	return false;
	    }
	    	
    }
    edocMarkObj = document.getElementById("my:serial_no");
    if(edocMarkObj && edocMarkObj.value){
        if(!isEdocMarkWellFormated(edocMarkObj.value)) return false;
    	var innerMark = "";
    	if(edocMarkObj.value.indexOf("|")==-1){
    		innerMark = edocMarkObj.value;
    	}else{
    		var arr = edocMarkObj.value.split("|");
    		if(arr && arr.length>1)
    			innerMark = arr[1];
    	}
    	if(innerMark.length>66){
    		alert(v3x.getMessage("edocLang.innermark_alter_exceed"));
    		return false;
    	}
    }
    return true;
}
function updateAtt(summaryId,processId){
	if(!checkModifyingProcess(processId, summaryId)){
		return;
	}
	//var detailFrame =  parent.parent.detailMainFrame;
	var attList = getAttachment(summaryId,summaryId);
	
	var result = editAttachments(attList,summaryId,summaryId,'4');
	if(result){
		updateAttachmentMemory(result,summaryId,summaryId,'')
		showAttachment(summaryId, 2, 'attachment2TrContent', 'attachment2NumberDivContent','attachmentHtml2Span');
		showAttachment(summaryId, 0, 'attachmentTrContent', 'attachmentNumberDivContent','attachmentHtml1Span');
		
		//changyi add 显示附件(开始没有附件时就不显示)
		if(theToShowAttachments){
			var attachmentNumber = 0;
			for(var i = 0; i < theToShowAttachments.size(); i++) {
				var att  = theToShowAttachments.get(i);
				if(att.subReference == summaryId && att.type == 0){
					attachmentNumber++;
				}
			}
			if(attachmentNumber > 0){
				var tt =  document.getElementById("attachment2Tr");
				if(tt){
					tt.style.display="";
				}
			}
		}
	}
}
/**
 * 对归档Select对象的不同选择做出不同的操作
 * @param obj : 当前下拉选择框对象
 * @param appName : 应用名
 * @param from : 来源（模板、处理页面）
 * @param formObj : form对象
 */
function pigeonholeEvent(obj,appName,from,formObj){
	switch(obj.selectedIndex){
		case 0 :
			var oldArchiveId = formObj.archiveId.value;
			if(oldArchiveId != ""){
				formObj.archiveId.value = "";
			}
			break;
		case 1 : 
			doPigeonhole('new', appName, from,formObj);
			break;
			
		default :
			formObj.archiveId.value = document.getElementById("prevArchiveId").value;
			return;
	}
}

/**
 * 弹出归档选择文件路径界面
 * @param obj : 当前下拉选择框对象
 * @param appName : 应用名
 * @param from : 来源（模板、处理页面）
 * @param formObj : form对象
 */
function doPigeonhole(flag,appName,from,formObj) { 
    if(!formObj)  //已办公文页面单位归档
       formObj = document.getElementById("listForm");
    
    if (flag == "no") {
        //TODO 清空信息
    }
    else if (flag == "new") {
        var result;
    	if(from == "templete"){//公文模板预归档
        	result = pigeonhole(appName, null, false, false,'EdocTempletePrePigeonhole');
    	}else{
    		result = pigeonhole(appName,null,false,true,'EdocAccountPigoenhole');
    	}
    	//var theForm = document.getElementsByName("sendForm")[0];
        if(result == "cancel"){
        	var oldPigeonholeId = formObj.archiveId.value;
    		var selectObj = formObj.selectPigeonholePath;
    		if(selectObj){ //存在下拉选择框的情况
            	if(oldPigeonholeId != "" && selectObj.options.length >= 3){
    				selectObj.options[2].selected = true;
            	}
            	else{
            		var oldOption = document.getElementById("defaultOption");
            		oldOption.selected = true;
            	}
    		}
        	return;
        }
        var pigeonholeData = result.split(",");
        pigeonholeId = pigeonholeData[0];
        pigeonholeName = pigeonholeData[1];
        if(pigeonholeId == "" || pigeonholeId == "failure"){
        	formObj.archiveName.value = "";
        	alert(v3x.getMessage("collaborationLang.collaboration_alertPigeonholeItemFailure"));
        }
        else{
        	var oldPigeonholeId = formObj.archiveId.value;
        	formObj.archiveId.value = pigeonholeId;
        	if(document.getElementById("prevArchiveId")){
        		document.getElementById("prevArchiveId").value = pigeonholeId;
        	}
        	var selectObj = document.getElementById("selectPigeonholePath");
        	if(selectObj){
            	var option = document.createElement("OPTION");
            	option.id = pigeonholeId;
            	option.text = pigeonholeName;
            	option.value = pigeonholeId;
            	option.selected = true;
            	if(oldPigeonholeId == "" && selectObj.options.length<=2){
            		selectObj.options.add(option, selectObj.options.length);
            	}
            	else{
            		selectObj.options[selectObj.options.length-1] = option;
            	}
        	}
        }
    }
}
/**
 * 根据文档的逻辑路径取文档的真实路径
 * @param logicalPath :逻辑路径
 */
function showWholePath(logicalPath,callObj){
        if(logicalPath == '' )return;
    	var requestCaller = new XMLHttpRequestCaller(this, "ajaxEdocController", "getPhysicalPath", false);
		requestCaller.addParameter(1,"String", logicalPath);
		requestCaller.addParameter(2,'String',"\\");
		requestCaller.addParameter(3,'boolean',false);
		requestCaller.addParameter(4,'int',0);
		var rs = requestCaller.serviceRequest();
		callObj.title=rs;
}

//批处理
function batchEdoc(){
	var checkBoxs = document.getElementsByName("id");
	if(!checkBoxs){
		alert(_("edocLang.batch_select_affair"));
		return ;
	}
	var process = new BatchProcess();
	for(var i = 0 ; i < checkBoxs.length;i++){
		if(checkBoxs[i].checked){
			var affairId = checkBoxs[i].getAttribute("affairId");
			var subject = checkBoxs[i].getAttribute("subject");
			var app = "4";
			process.addData(affairId,checkBoxs[i].value,app,subject);
		}
	}
	if(!process.isEmpty()){
		var r = process.doBatch("getA8Top().contentFrame.topFrame.refreshWorkspace()");
	}else{
		alert(_("edocLang.batch_select_affair"));
		return ;
	}
}
function opinionInputWindow(tempOpinion,canUploadRel,relAttButton,canUploadAttachment,attButton,attContfileUpload,attitude,commonPhrase){
	var window = "<table id='opinionInputArea' width='100%'  border='0' cellspacing='0' cellpadding='0' class='sign-area'>";
		
		window += "<tr>";
		window += "<td align='left'>"+attitude+"</td>";//态度 
		window += "<td align='right'>"+commonPhrase+"</td>";
		window +="</tr>";	
		
		window += "<tr><td colspan='2'>"
		window += "<textarea id='content' name='content' rows='5' style='width: 100%' validate='maxLength' maxSize='2000'>"+tempOpinion+"</textarea>";
		window += "</td></tr>";
		//推送消息
		window += "<tr><td colspan='2' align='right'>"
		window += pushMessage;
		window += "</td></tr>";
		
		if(canUploadRel || canUploadAttachment){
			window += "<tr><td colspan='2' style='padding: 5px 10px;'>";
			window += "<div height='36'>";
			if(canUploadRel){
				window += relAttButton +"&nbsp;&nbsp;";
			}
			if(canUploadAttachment){	
				window += attButton;
			}	
			window += "</div>"
			window +="</td></tr>"
				
			window += "<tr><td colspan='2'>"	;
			window += ' <div id="attachment2Area" style="overflow: auto;"></div>';
			window += '	<div id="attachmentInputs"></div>'
			window += attContfileUpload;
			window += '</td></tr></table>'
		}
		
		return window;
}
function showSupervise(summaryId,openModal){
	getA8Top().v3x.openWindow({
        url: genericURL + "?method=superviseDiagram&summaryId=" + summaryId + "&openModal=" + openModal,
        dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
        width: "350",
        height: "450"
    });
}
/**
 * 查看属性
 */
function showAttribute(affairId, from){
	getA8Top().v3x.openWindow({
        url: colWorkFlowURL + "?method=showAttribute&affairId=" + affairId + "&from=" + from,
        dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
        width: "350",
        height: "400"
    });
}
function getSelectIds(frame){
	var ids=frame.document.getElementsByName('id');
	var id='';
	for(var i=0;i<ids.length;i++){
		var idCheckBox=ids[i];
		if(idCheckBox.checked){
			if(id == ''){
				id = idCheckBox.value;
			}else{				
				id += ','+idCheckBox.value;
			}
		}
	}
	return id;
}
/***阅文批处理**/
function readBatch(){
	var checkBoxs = document.getElementsByName("id");
	//if(!checkBoxs){
		//alert(_("collaborationLang.batch_select_affair"));
		//return ;
	//}
	var process = new BatchProcess();
	for(var i = 0 ; i < checkBoxs.length;i++){
		if(checkBoxs[i].checked){
			var affairId = checkBoxs[i].getAttribute("affairId");
			var subject = checkBoxs[i].getAttribute("colSubject");
			var app =  checkBoxs[i].getAttribute("category")||"1";
			process.addData(affairId,checkBoxs[i].value,app,subject);
		}
	}
	if(!process.isEmpty()){
		var r = process.doBatch("getA8Top().contentFrame.topFrame.refreshWorkspace()");
	}else{
		alert(_("collaborationLang.batch_select_affair"));
		return ;
	}
}

/***
 * 彈出閱文批量分發界面
 */
function showReadBatchWD(){
	var checkObj;
	var checkbox = document.getElementsByName("id");
	var checkedNum = 0;
	var objs = [];
	var len = checkbox.length;
	for (var i = 0; i < len; i++) {
		if (checkbox[i].checked) {      
			objs[checkedNum] = checkbox[i];
			checkedNum ++;
			if(checkedNum==1){
				checkObj=checkbox[i];
			}
	    }
	}
    var sendForm = $("#sendForm");
    if(objs.length<1){
		alert(_("collaborationLang.batch_select_affair"));
		return ;
     }
    sendForm.innerHTML="";
    for(var i=0; i<objs.length; i++) {
    	sendForm.append("<input type='hidden' name='registerId'  value='"+objs[i].registerId+"'/>");
    }
	var _url= genericURL+"?method=readBatchWD";
	var re= v3x.openWindow({
			url: _url,
			height : 300,
			width  : 400
     });
	if(re=='True'){
			//隐藏域的form表单 
		var theForm = document.getElementsByName("sendForm")[0];
		var _sendUrl=genericURL+"?method=readBatch";
		theForm.action=_sendUrl;
		theForm.submit();
	 }
}

/**页面校验
**/
function checkFormBacth(){
	var val= document.getElementById("note").value;
	var valfw= document.getElementById("workflowInfo").value;
	if(valfw=='<点击新建流程>'){
		alert(_("edocLang.edoc_selectWorkflow"));
		return ;
	}
	var _parent = window.opener;
	if(_parent == null){
		_parent = window.dialogArguments;
	}
	_parent.document.getElementById("note").value= val;
	window.returnValue="True";
	window.close();
}

function setBatchPeopleFields(elements, frameNames) {
	//alert(elements);
	//alert(frameNames);
	var _parent = window.opener;
	if(_parent == null){
		_parent = window.dialogArguments;
	}
    var theForm = _parent.document.getElementsByName("sendForm")[0];
    theForm.document.getElementById("people").innerHTML = "";
    if (!elements) {
        return false;
    }

    var personList = elements[0] || [];
    var flowType = elements[1] || 0;
    var isShowShortName = elements[2];
    var isShowWorkflow = (flowType == "2");
    //多层    

    if (isShowWorkflow) {
        flowType = 0;
        elements[1]=0;
    }

    var str = "";
    var workFlowContent = "";
    for (var i = 0; i < personList.length; i++) {
    	if(i > 0){
    		workFlowContent += ",";
    	}
        var person = personList[i];
        str += '<input type="text" name="userType" value="' + person.type + '" />';
        str += '<input type="text" name="userId" value="' + person.id + '" />';
        str += '<input type="text" name="userName" value="' + escapeStringToHTML(person.name) + '" />';
        str += '<input type="text" name="accountId" value="' + person.accountId + '" />';
        str += '<input type="text" name="accountShortname" value="' + escapeStringToHTML(person.accountShortname) + '" />';

        workFlowContent += person.name + "("+defaultPermName+")";
    }

    str += '<input type="text" name="flowType" value="' + flowType + '" />';

    _parent.document.getElementById("people").innerHTML = str;

    hasWorkflow = true;
    isFromTemplate = false;
    document.getElementById("workflowInfo").value = workFlowContent;
    _parent.document.getElementById("workflowInfo").value = workFlowContent;
    _parent.theForm.process_desc_by.value = 'people';//
    window.selectedElements = elements;

    if (isShowWorkflow) {    //显示流程
        designWorkFlow(frameNames);
    }

    return true;
}



//点击归档编辑图标编辑已归档公文单
function editFromArchived()
{
	try{
		var id_checkbox = document.getElementsByName("id");
	    if (!id_checkbox) {
	        return;
	    }
	    var count = validateCheckbox("id");
	    if(count == 1){
	    	for(var i=0; i<id_checkbox.length; i++){
				var idCheckBox = id_checkbox[i];
				if(idCheckBox.checked){
					var summaryId = idCheckBox.value;
					var affairId =  idCheckBox.affairId;
					location.href=genericURL+"?method=newEdoc&notOpenSave=true&summaryId="+summaryId+"&from=archived&affairId="+affairId;
				}
			}
	    }
	    else if(count == 0){
	    	alert(v3x.getMessage("edocLang.edoc_alertSelectEditItem"));
	        return;
	    }
	    else{
	    	alert(v3x.getMessage("edocLang.edoc_alertDontSelectMulti"));
	 		return;
	    }
	}catch(e){
	}
}

//点击归档修改历史
function showArchiveModifyLog()
{
	try{
		var id_checkbox = document.getElementsByName("id");
	    if (!id_checkbox) {
	        return;
	    }
	    var count = validateCheckbox("id");
	    if(count == 1){
	    	for(var i=0; i<id_checkbox.length; i++){
				var idCheckBox = id_checkbox[i];
				if(idCheckBox.checked){
					var summaryId = idCheckBox.value;
					var url = edocURL + "?method=showArchiveModifyLog&summaryId="+summaryId ;
					//v3x.openWindow({
					//	url		: url,
					//	width	: 750,
					//	height	: 500,
					//	resizable	: "yes"
					//});
					
					getA8Top().v3x.openWindow({
				        url: edocURL + "?method=showArchiveModifyLog&summaryId=" + summaryId,
				        dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
				        width: "750",
				        height: "500"
				    });
					
				}
			}
	    }
	    else if(count == 0){
	    	alert(v3x.getMessage("edocLang.edoc_alertSelectShowHistoryItem"));
	        return;
	    }
	    else{
	    	alert(v3x.getMessage("edocLang.edoc_alertDontSelectMulti"));
	 		return;
	    }
	}catch(e){
	}
}

//lijl添加
function showArchiveModifyLog_iframe()
{
	try{
		var id_checkbox = document.getElementsByName("id");
	    if (!id_checkbox) {
	        return;
	    }
	    var count = validateCheckbox("id");
	    if(count == 1){
	    	for(var i=0; i<id_checkbox.length; i++){
				var idCheckBox = id_checkbox[i];
				if(idCheckBox.checked){
					var summaryId = idCheckBox.value;
					getA8Top().v3x.openWindow({
				        url: edocURL + "?method=showArchiveModifyLog_Iframe&summaryId=" + summaryId,
				        dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
				        width: "750",
				        height: "500"
				    });
					
				}
			}
	    }
	    else if(count == 0){
	    	alert(v3x.getMessage("edocLang.edoc_alertSelectShowHistoryItem"));
	        return;
	    }
	    else{
	    	alert(v3x.getMessage("edocLang.edoc_alertDontSelectMulti"));
	 		return;
	    }
	}catch(e){
	}
}


/**
 * 归档修改保存
 */
function saveArchived() {
	var isFormChanged=is_form_changed(); //文单是否被修改的标识，放到方法最前面，避免中间过程修改了文单
    if(!checkEdocMark()) return;
	// 验证交换单位是否有重复 -- start --
	var bool = checkExchangeAccountIsDuplicatedOrNot();
	
	if(bool == false){
		alert(_("edocLang.exchange_unit_duplicated"));
		return;
	}

    var theForm = document.getElementsByName("sendForm")[0];
    theForm.action = genericURL + "?method=saveArchived";
    
	if(validFieldData()==false){return;}
	if(compareTime()==false){return;}
	

	
	// 节点权限引用更新
	if(!isCheckNodePolicyFlag){
		var policyArr = new Array();
	    var itemNameArr = new Array();
	    if(nodes != null && nodes.length>0){
	    	for(var i=0;i<nodes.length;i++){
	    		var policyName = policys[nodes[i]].name;
	    		var itemName = policys[nodes[i]].value;
	    		policyArr.push(policyName);
	    		itemNameArr.push(itemName);
	    	}
	    }
		try {
			var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "checkNodePolicy", false);
			requestCaller.addParameter(1, "String[]", policyArr);
			requestCaller.addParameter(2, "String[]", itemNameArr);
			requestCaller.addParameter(3, "String", theForm.loginAccountId.value);
			var rs = requestCaller.serviceRequest();
			if(rs == "1"){
				alert(_("collaborationLang.node_policy_not_existence"));
				enableButtons();
				return;
			}
		}
		catch (ex1) {
			alert("Exception : " + ex1);
			return;
		}
	}	
	
    if (checkForm(theForm)) {
    	// 标题不能为空并且不含有特殊字符
    	if(!checkSubject(theForm)){return;}
    	// 检查主送单位、主送单位2的是否设置有值，屏蔽，不需要验证主送单位
		//if(!checkSendUnitAndSendUnit2(theForm)){return;}

        // 检查签报公文文号是否已使用
        var edocMarkObj = document.getElementById("my:doc_mark");
        if(edocMarkObj){
	        var edocMark = _getWordNoValue(edocMarkObj);
	        var edocType = document.getElementById("edocType").value;
	        var summaryId=document.getElementById("summaryId").value;
	        if(edocType == "2" && edocMark != "" && !loadAndManualSelectedPreSend && checkMarkHistoryExist(edocMark,summaryId)){
	        	return;
	        }
        }
        // 保存正文
       // checkExistBody();
    	if(isFormChanged){//文单修改标识
    		document.getElementById("isModifyForm").value="1";
    	} 
    	if(ocxContentIsModify()){//正文修改标识
    		document.getElementById("isModifyContent").value="1";
    	} 
    	if(is_att_changed()){//附件修改标识
    		document.getElementById("isModifyAtt").value="1";
    	} 
       	fileId=newEdocBodyId;
        if (!saveOcx()) {
            return;
        }
        saveAttachment();
        disableButtons();

        isFormSumit = true;
        theForm.target = "_self";
        try{adjustReadFormForSubmit();}catch(e){}
        try {
        	theForm.submit();
        } catch(e) {
        	reductClick(false);
            topLinkClick(false);
        }
        getA8Top().startProc('');
        reductClick(false);
        topLinkClick(false); 
        
    }
}
//判断文单是否被修改，只可用于newedoc
function is_form_changed() { 
    var formIsChange = false;
	$("input[@id*='my:']").each(function() { 
		var _v = jQuery(this).attr('_value'); 
		if(typeof(_v) == 'undefined') _v = ''; 
		if(_v != jQuery(this).val()){
			//alert(_v +"_"+jQuery(this).val());
			formIsChange = true;
		}
	}); 
	
	$("select[@id*='my:']").each(function() { 
		var _v = jQuery(this).attr('_value'); 
		if(typeof(_v) == 'undefined') _v = ''; 
		if(_v != jQuery(this).val()){
			//alert(_v +"_"+jQuery(this).val());
			formIsChange = true;
		}
	}); 
	
	$("textarea[@id*='my:']").each(function() { 
		var _v = jQuery(this).attr('_value'); 
		if(typeof(_v) == 'undefined') _v = ''; 
		if(_v != jQuery(this).val()){
			//alert(_v +"_"+jQuery(this).val());
			formIsChange = true;
		}
	}); 
	
	return formIsChange; 
}

//判断附件是否被修改，只可用于newedoc
function is_att_changed() { 
	//关联文档
	var _v = $("#attachmentArea").attr('_value'); 
	var _w = $("#attachmentArea").html();
	if(typeof(_v) == 'undefined') _v = ''; 
	if(typeof(_w) == 'undefined') _w = ''; 

	if(_v != _w){
		return true;
	}
	
	//附件
	_v = $("#attachment2Area").attr('_value'); 
	_w = $("#attachment2Area").html();
	if(typeof(_v) == 'undefined') _v = ''; 
	if(typeof(_w) == 'undefined') _w = ''; 

	if(_v != _w){
		return true;
	}

	return false; 
}


//归档修改公文，返回
function returntolist(){
	location.href='edocController.do?method=listFinish&edocType=0&list=doneOver&hasArchive=1';
}


var isCombSearchFlag=false; //是否执行了组合查询
/**
 * 组合查询按钮事件,edocType 0:发文，1：收文， 2：签报;  state 1 待发,2已发,3待办,4已办
 */
function combQueryEvent(edocType,state){
	//打开组合查询界面
	openCombQuery(edocType,state);
	
	if(!isCombSearchFlag){return;}else{isCombSearchFlag=false;}  //是否直接关闭了组合查询窗口
	
	//获取对象参数， 执行查询
	var combform=document.getElementById("combForm");

    document.getElementById("comb_condition").value="1";
    
    document.getElementById("comb_subject").value=combQueryObj.subject;
    document.getElementById("comb_keywords").value=combQueryObj.keywords;
    document.getElementById("comb_docMark").value=combQueryObj.docMark;
    document.getElementById("comb_serialNo").value=combQueryObj.serialNo;
    document.getElementById("comb_createPerson").value=combQueryObj.createPerson;
    document.getElementById("comb_createTimeB").value=combQueryObj.createTimeB;
    document.getElementById("comb_createTimeE").value=combQueryObj.createTimeE;
    document.getElementById("comb_sendUnit").value=combQueryObj.sendUnit;
    document.getElementById("comb_secretLevel").value=combQueryObj.secretLevel;
    document.getElementById("comb_urgentLevel").value=combQueryObj.urgentLevel;
    document.getElementById("comb_receiveTimeB").value=combQueryObj.receiveTimeB;
    document.getElementById("comb_receiveTimeE").value=combQueryObj.receiveTimeE;
    document.getElementById("comb_registerDateB").value=combQueryObj.registerDateB;
    document.getElementById("comb_registerDateE").value=combQueryObj.registerDateE;
    document.getElementById("comb_recieveDateB").value=combQueryObj.recieveDateB;
    document.getElementById("comb_recieveDateE").value=combQueryObj.recieveDateE;
    
    var methodStr="";
    if(state==3){
    	methodStr="listPending";
    }else if(state==4){
    	methodStr="listDone&edocType="+edocType; 
    }else if(state==5){
    	methodStr="listZcdb";
    }else if(state==6){
    	methodStr="listFinish";
    }else if(state==7){
    	methodStr="listReading";
    }else if(state==8){
    	methodStr="listReaded";
    }
    
    combform.action = edocURL + "?method="+methodStr;
    combform.submit();
}


/**
 * 组合查询窗口,edocType 0:发文，1：收文， 2：签报;  state 1 待发,2已发,3待办,4已办
 */
function openCombQuery(edocType,state){
	var url = edocURL + "?method=openCombQuery&edocType=" + edocType+"&state="+state;

	v3x.openWindow({
		url		: url,
		width	: 600,
		height	: 280,
		resizable	: "no"
	});
}


/**
 * 组合查询对象
 * 
 */
function CombQueryObj(
		subject,
		docMark,
		serialNo,
		createPerson,
		createTimeB,
		createTimeE,
		secretLevel,
		urgentLevel,
		keywords,
		receiveTimeB,
		receiveTimeE,
		sendUnit,
		registerDateB,
		registerDateE,
		recieveDateB,
		recieveDateE
){
	
	this.subject = subject; //标题
	this.docMark = docMark;  //公文文号
	this.serialNo = serialNo; //内部文号
	this.createPerson = createPerson;  //发起人
	this.createTimeB = createTimeB;  //发起时间开始
	this.createTimeE = createTimeE;  //发起时间结束
	this.secretLevel=secretLevel;  //密级
	this.urgentLevel=urgentLevel;  //紧急程度
	
	//以下字段发文待办已办、收文待阅已阅才有
	this.keywords = keywords; //主题词 
	this.receiveTimeB=receiveTimeB; //到达时间开始
	this.receiveTimeE=receiveTimeE; //到达时间结束
	
	//以下收文待办已办才有
	this.sendUnit = sendUnit; //成文单位
	this.registerDateB =registerDateB;//登记时间开始
	this.registerDateE =registerDateE;//登记时间结束
	this.recieveDateB =recieveDateB;//签收时间开始
	this.recieveDateE =recieveDateE;//签收时间结束
	
}

//组合查询封装查询值对象
function addCombQueryObj(
		subject,
		docMark,
		serialNo,
		createPerson,
		createTimeB,
		createTimeE,
		secretLevel,
		urgentLevel,
		keywords,
		receiveTimeB,
		receiveTimeE,
		sendUnit,
		registerDateB,
		registerDateE,
		recieveDateB,
		recieveDateE
){
	combQueryObj=new CombQueryObj(
									subject,
									docMark,
									serialNo,
									createPerson,
									createTimeB,
									createTimeE,
									secretLevel,
									urgentLevel,
									keywords,
									receiveTimeB,
									receiveTimeE,
									sendUnit,
									registerDateB,
									registerDateE,
									recieveDateB,
									recieveDateE
	                             );
}


function onbeforeunload() {
	if(clickFlag) {
		return "";
	}
}

function saveAsDraft(checkFlag) {
	var theForm = document.getElementsByName("sendForm")[0];
   theForm.action = genericURL + "?method=save";
	if(document.getElementById("my:subject") && document.getElementById("my:subject")=="") {
  	document.getElementById("my:subject").value = "(请输入标题)";	
  }
  if(!isCheckNodePolicyFlag){
		var policyArr = new Array();
	    var itemNameArr = new Array();
	    if(nodes != null && nodes.length>0){
	    	for(var i=0;i<nodes.length;i++){
	    		var policyName = policys[nodes[i]].name;
	    		var itemName = policys[nodes[i]].value;
	    		policyArr.push(policyName);
	    		itemNameArr.push(itemName);
	    	}
	    }
		try {
			var requestCaller = new XMLHttpRequestCaller(this, "ajaxColManager", "checkNodePolicy", false);
			requestCaller.addParameter(1, "String[]", policyArr);
			requestCaller.addParameter(2, "String[]", itemNameArr);
			requestCaller.addParameter(3, "String", theForm.loginAccountId.value);
			var rs = requestCaller.serviceRequest();
			if(rs == "1"){
				alert(_("collaborationLang.node_policy_not_existence"));
				enableButtons();
				return;
			}
		}
		catch (ex1) {
			alert("Exception : " + ex1);
			return;
		}
	}	
	if(document.getElementById("my:subject") && document.getElementById("my:subject").value=="") {
        	document.getElementById("my:subject").value = "(请输入标题)";	
        }
        //保存正文
       // checkExistBody();
       	fileId=newEdocBodyId;
        if (!saveOcx()) {
            return;
        }
	saveAttachment();
        disableButtons();
        isFormSumit = true;
        theForm.target = "_self";
        try{adjustReadFormForSubmit();}catch(e){}
        theForm.submit();	
	
}

//退回拟稿人：拟稿人的发送动作
function sendBackToDraft(theForm){
	if(!checkModifyingProcessAndLock(theForm.processId.value, theForm.summary_id.value)){
		return;
	}
	$('#processModeSelectorContainer').html("");
	if (checkForm(theForm)){
		if(!window.confirm(v3x.getMessage("edocLang.edoc_sendBackToDraft_confirm")))
			return;
		if(typeof beforeSubmitButton)
			beforeSubmitButton();
		if(!contentIframe.saveEdocForm()){
	  		return;
		}
		if(!contentIframe.saveContent()){
	  		return;
		}
		if(!contentIframe.saveHwData()){
	  		return;
		}
        theForm.action = genericURL + "?method=sendBackToDraft";
        saveAttachment();
        document.getElementById("processButton").disabled = true;
        try {
            document.getElementById("zcdbButton").disabled = true;
        } catch(e) {
        }
        
	    try { //如果是弹出窗口，则不能显示“处理中”
	        getA8Top().startProc('');
	    }
	    catch (e) {
	    }
	    
	    disableButton("stepStopSpan");
	    disableButton("stepBackSpan");
	    disableButton("sendBackToDraftDiv");
        theForm.submit();
	}
}

//退回拟稿人：拟稿人发送时弹出选择是重新发起还是回到退稿人
function showDraftChoose(){
	var rv = getA8Top().v3x.openWindow({
        url: genericControllerURL + "edoc/showDraftChoose",
        dialogType : v3x.getBrowserFlag('openWindow') == true ? "modal" : "1",
        width: "250",
        height: "150"
    });
	if(!rv)
		return;
	else{
		var choose = document.getElementById("draftChoose");
		var theForm = document.getElementById("sendForm");
		if(choose){
			choose.value = rv;
			//如果返回到回退人，不需要匹配后续分支、人员
			if(rv=="toContinue"){
				loadAndManualSelectedPreSend = true;
			}
			if(theForm){
				theForm.action = genericURL = "?method=beforeDraftSendHandle";
				send();
			}
		}
	}
}

//原左侧导航收起
function onLoadLeft(){
	try {
		if(getA8Top().contentFrame.document.getElementById("LeftRightFrameSet").cols != "132,*"){
			getA8Top().contentFrame.leftFrame.closeLeft("yes");
		}
	} catch(e) {}
}

//原左侧导航展开
function unLoadLeft(){
	try {
		getA8Top().contentFrame.leftFrame.closeLeft();
	} catch(e) {}
}

/**
 * 山西太原市政府二开项目  回退、取回时还原原始文单  郝后成  2012-07-26 start
 */
function undoEdocForm(affairId,summaryId,isTakeBack){
	var edocType = document.getElementById("edocType").value;

	if(edocType == 2){ //签报
	    $.ajax({
		   type: "POST",
		   async: false,
		   url: "/seeyon/edocForm.do?method=checkParentNodeIsShangKa",
		   data: "affairId=" + affairId + "&summaryId=" + summaryId,
		   success: function(retData){
			   	var formId = retData;
			   	
				 if(formId != -1){ //如果当前操作节点的父节点包含“上卡"权限的节点，则交换”文单“与”请示卡“的div内容
					 
					 if(isTakeBack){ //取回操作时要还原原始文单需用另外一种方式
						 
						 document.getElementById("summaryId").value = summaryId;
						 document.getElementById("affairId").value = affairId;
						 
						 //取得原始文单的id
						 $.ajax({
							   type: "POST",
							   async: false,
							   url: "/seeyon/edocForm.do?method=getBeforeShangKaFormId",
							   data: "summaryId=" + summaryId,
							   success: function(data){
								   if(data != -1){
										 document.getElementById("edoctable").value = data;
									 }
							   }
						 });
						 
						 $.ajax({
							   type: "POST",
							   async: false,
							   url: "/seeyon/edocForm.do?method=getChangeCardInfo",
							   data: "summaryId=" + summaryId,
							   success: function(data){
								   if(data != -1){
									   var showEdocFormDiv = document.getElementById("showEdocFormDiv");
										 showEdocFormDiv.innerHTML = data;
										 
										 applyCansubmitAttToDiv(showEdocFormDiv);
										 
										 isUpdateEdocForm = true;
										 
										 if(saveEdocForm()){ //保存成功 则删除请示卡内容
											 deleteCardInfo(edocType,summaryId);
										 }
									 }
							   }
						 });
						 
					 }else{ //交换div内容
						 var cardDive = document.getElementById('cardDive');
						 var formAreaDiv = window.frames["contentIframe"].document.getElementById("formAreaDiv");
						 var edocTopicFormIdInput = window.frames["contentIframe"].document.getElementById("edoctable");
						 var formIdInput = document.getElementById("formId");
							
						 var cardDivContent = cardDive.innerHTML;
						 var formAreaContent = formAreaDiv.innerHTML;
						 $(cardDive).empty();
						 $(formAreaDiv).empty();
						 cardDive.innerHTML = formAreaContent;
						 formAreaDiv.innerHTML = cardDivContent;
						 
						 edocTopicFormIdInput.value = formId;
						 formIdInput.value = formId; 
						 
						 applyCansubmitAttToDiv(formAreaDiv);
						 
						 deleteCardInfo(edocType,summaryId);//删除请示卡内容
					 }
				 }
		   }
		});
	}
}

/**
 * 给文单所有的域添加cansubmit=true的属性
 */
function applyCansubmitAttToDiv(div){
	
	var allInput = div.getElementsByTagName("input");
	var allTextarea = div.getElementsByTagName("textarea");
	//var allSelect = div.getElementsByTagName("select");
	
	setAttr(allInput);
	setAttr(allTextarea);
	//setAttr(allSelect);
}

function setAttr(objArr){
	for(var i=0;i<objArr.length;i++){
		if($(objArr).eq(i).attr("realvalue") == undefined)
			$(objArr).eq(i).attr("canSubmit","true");
	}
}
//山西太原市政府二开项目  回退、取回时还原原始文单  郝后成  2012-07-26 end